This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot:examples:rgb [2021/03/04 23:26] – heiko.pikner | en:iot:examples:rgb [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| The example code above lights the RGB LED | The example code above lights the RGB LED | ||
| <code c> | <code c> | ||
| - | // Includes global variables and librarys that the RGB LED uses | ||
| #include < | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | |||
| + | #define MODULE_TOPIC " | ||
| + | #define WIFI_NAME " | ||
| + | #define WIFI_PASSWORD " | ||
| //Stating, to which PIN the RGB LED has been connected | //Stating, to which PIN the RGB LED has been connected | ||
| Line 40: | Line 43: | ||
| strIndex[1] = (i == maxIndex) ? i+1 : i; | strIndex[1] = (i == maxIndex) ? i+1 : i; | ||
| } | } | ||
| - | } | + | } |
| return found> | return found> | ||
| } | } | ||
| Line 52: | Line 55: | ||
| Serial.print(" | Serial.print(" | ||
| Serial.println(msg); | Serial.println(msg); | ||
| - | // Splitting the RGB values into smaller parts | ||
| - | String r = getValue(msg,';', | ||
| - | String g = getValue(msg,';', | ||
| - | String b = getValue(msg,';', | ||
| - | Serial.print(" | + | |
| - | Serial.println(r); | + | { |
| + | // Splitting the RGB values into smaller parts | ||
| + | String r = getValue(msg,';', | ||
| + | String g = getValue(msg,';', | ||
| + | String b = getValue(msg,';', | ||
| + | |||
| + | | ||
| + | Serial.println(r); | ||
| - | | + | |
| - | Serial.println(g); | + | Serial.println(g); |
| - | | + | |
| - | Serial.println(b); | + | Serial.println(b); |
| - | | + | |
| - | pixels.setPixelColor(0, | + | pixels.setPixelColor(0, |
| - | pixels.show(); | + | pixels.show(); |
| + | } | ||
| } | } | ||
| Line 75: | Line 82: | ||
| { | { | ||
| Serial.println(" | Serial.println(" | ||
| - | iot.subscribe(" | + | iot.subscribe(MODULE_TOPIC); |
| iot.log(" | iot.log(" | ||
| } | } | ||
| Line 85: | Line 92: | ||
| Serial.println(" | Serial.println(" | ||
| + | // | ||
| + | // | ||
| iot.printConfig(); | iot.printConfig(); | ||
| iot.setup(); | iot.setup(); | ||
| Line 97: | Line 106: | ||
| delay(200); // Delay of 200 ms | delay(200); // Delay of 200 ms | ||
| } | } | ||
| + | |||
| </ | </ | ||