help in coding

Hi guys, i got an assignment in tinkercad and it concerns arduino, can someone help me make a basic circuit?
No description
3 Replies
Reeshav_Ghosh200
make separate redLed, blueLed ... variables set all of them to OUTPUT and digitalWrite({color}Led, 0) in setup then in loop
digitalWrite(redLed, 1);
delay(500)
digitalWrite(redLed, 0);
digitalWrite(orangeLed, 1);
... other LEDS
digitalWrite(whiteLed, 0);
delay(500)

digitalWrite(redLed, 1);
... other LEDS
digitalWrite(whiteLED, 1);

delay(2000)

digitalWrite(redLed, 0)
... other LEDs
digitalWrite(orangeLed, 0)

delay(1000)
digitalWrite(redLed, 1);
delay(500)
digitalWrite(redLed, 0);
digitalWrite(orangeLed, 1);
... other LEDS
digitalWrite(whiteLed, 0);
delay(500)

digitalWrite(redLed, 1);
... other LEDS
digitalWrite(whiteLED, 1);

delay(2000)

digitalWrite(redLed, 0)
... other LEDs
digitalWrite(orangeLed, 0)

delay(1000)
AnonEngineering
AnonEngineering2mo ago
or use an array
c++
const int NUM_LEDS = 6;
const int LED_PINS[] = {12, 11, 10, 9, 8, 7};

void setup() {
Serial.begin(115200);
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(LED_PINS[i], OUTPUT);
}
}
c++
const int NUM_LEDS = 6;
const int LED_PINS[] = {12, 11, 10, 9, 8, 7};

void setup() {
Serial.begin(115200);
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(LED_PINS[i], OUTPUT);
}
}
Reeshav_Ghosh200
using arrays works very well ik, but i think this is meant to be a beginner friendly project

Did you find this page helpful?