This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:practical:hardware:rtu:robotnest:rgb-led [2025/07/30 09:02] – kivilands6 | en:iot-open:practical:hardware:rtu:robotnest:rgb-led [2025/07/30 09:05] (current) – kivilands6 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Step 1 ===== | ====== Step 1 ===== | ||
| - | define | + | Define |
| < | < | ||
| /* RGB LEDS */ | /* RGB LEDS */ | ||
| Line 12: | Line 12: | ||
| </ | </ | ||
| ====== Step 2 ===== | ====== Step 2 ===== | ||
| - | define | + | Define |
| < | < | ||
| void setup() { | void setup() { | ||
| Line 23: | Line 23: | ||
| </ | </ | ||
| ====== Step 3 ===== | ====== Step 3 ===== | ||
| + | Add a function at the end of the code: | ||
| + | < | ||
| + | void setRGB(int red, int green, int blue) { | ||
| + | analogWrite(RED_PIN, | ||
| + | analogWrite(GREEN_PIN, | ||
| + | analogWrite(BLUE_PIN, | ||
| + | } | ||
| + | </ | ||
| ====== Step 4 ===== | ====== Step 4 ===== | ||
| + | Write some code for the LED's (circle through red, green, blue light): | ||
| + | < | ||
| + | void loop() { | ||
| + | setRGB(255, 0, 0); | ||
| + | delay(1000); | ||
| + | setRGB(0, 255, 0); | ||
| + | delay(1000); | ||
| + | setRGB(0, 0, 255); | ||
| + | delay(1000); | ||
| + | } | ||
| + | </ | ||