Project 01: Blinking lights

Post Reply
c7
Posts: 1
Joined: Tue Apr 22, 2025 2:07 pm

Project 01: Blinking lights

Post by c7 »

This is a simple example using the arduino to blink 3 LED's. Though with a few changes to the code you can make it blink as many as you want ;)

Code: Select all

//Project 01: Blinking lights.
//Led's are on pins 10, 7, 4.

int leds[3] = {10, 7, 4};
const int ledsCount = sizeof(leds) / sizeof(leds[0]);
int led = 0;

void setup() {
  //This runs at the start of the program once. As setup!
  //Pinmode sets the function of a pin, so if you want to write to pin 8 you have to set its pinmode to OUTPUT.
  for(int i = 0; i < ledsCount; i++)
    pinMode(leds[i], OUTPUT);
}

void loop() {
  //This runs after setup, in a loop until the end of time. (or your arduino turns off.)
  // V This is digital, so HIGH means 5V and LOW means 0V (basically ON and OFF). 
  digitalWrite(leds[led], HIGH);
  delay(250);
  digitalWrite(leds[led], LOW);

  if(++led >= ledsCount)
    led = 0;
}
Attachments
Circuit Deisgn
Circuit Deisgn
Screenshot 2025-04-24 at 15-28-41 Circuit design Frantic Bigery-Curcan - Tinkercad.png (178.57 KiB) Viewed 55779 times
Post Reply