× Introduction Embedded systems Arduino Arduino Programming Structure Arduino Hardware Digital Output DO Projects Digital Input Analog I/O Variables and Strings Serial Communication Examples Quiz-1
eBooks
Arduino Uno
Components
Computer
Tools
C Programs







Digital Output Projects

Blink a LED

Turn an LED on for one second, off for one second, and repeat forever.

void setup()
{
  pinMode(13, OUTPUT);
}
void loop()
{
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);      
}

Flasher Lights

Turn ON Red LED, Turn OFF Green LED for one second, Turn OFF Red LED, Turn ON Green LED for one second, and repeat forever.

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
}

void loop()
{  
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  delay(1000);   
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  delay(1000); 
}

Traffic Lights

Switch ON red LED and Switch OFF yellow and green LEDs for 5 secs.
Switch ON yellow LED and Switch OFF red and green LEDs for 2 secs.
Switch ON green LED and Switch OFF yellow and green LEDs for 5 secs.

int greenLed = 2;
int yellowLed = 3;
int redLed = 4;

void setup()
{
  pinMode(greenLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  
  digitalWrite(greenLed, LOW);
  digitalWrite(yellowLed, LOW);
  digitalWrite(redLed, LOW);
}

void loop()
{
  digitalWrite(redLed, HIGH); 
  
  delay(5000);
  
  digitalWrite(yellowLed, HIGH);
  digitalWrite(redLed, LOW);
  
  delay(2000);
  
  digitalWrite(greenLed, HIGH); 
  digitalWrite(yellowLed, LOW);
  digitalWrite(redLed, LOW);
  
  delay(5000);
  
  digitalWrite(greenLed, LOW); 
  
  }

Homework Projects

Project-1

Project-2

Project-3

Project-4

Project-5

Project-6

Project-7

Project-8