//Arduino Traffic Light Controller //Requirements: /* * 1-Arduino Mega or Uno * 2-Red LED x4 * 3-Yellow LED x4 * 4-Blue or Green LED x4 */ //Description: /* * With this code you can make a Arduino Traffic Light Controller. * The duration of RED and BLUE LED is set to 15 Seconds. The duration of Yellow LED is set to 1 Second. * You can set your own duration by modifying the following code. */ //Pin-outs: /* * Pin outs of Arduino board and LED's are given following: * Arduino || LED's * ========================================================== * 8 L3 (Blue) , L4 (Blue) * 9 L3 (Yellow) , L4 (Yellow) * 10 L3 (Red) , L4 (Red) * 11 L1 (Blue) , L2 (Blue) * 12 L1 (Yellow) , L2 (Yellow) * 13 L1 (Red) , L2 (Red) * GND All negative terminals of LED's * ========================================================== */ //Note: /* * ======================================================================== * For LED allocation, also concern "plot" figure attached with the project. * ======================================================================== */ #define red1 13 #define yellow1 12 #define blue1 11 #define red2 10 #define yellow2 9 #define blue2 8 void setup() { pinMode(red1,OUTPUT); pinMode(yellow1,OUTPUT); pinMode(blue1,OUTPUT); pinMode(red2,OUTPUT); pinMode(yellow2,OUTPUT); pinMode(blue2,OUTPUT); } void loop() { digitalWrite(red1,HIGH); digitalWrite(yellow1,LOW); digitalWrite(blue1,LOW); digitalWrite(red2,LOW); digitalWrite(yellow2,LOW); digitalWrite(blue2,HIGH); delay(5000); //Red LED Delay delay(5000); delay(5000); digitalWrite(red1,LOW); digitalWrite(yellow1,HIGH); digitalWrite(blue1,LOW); digitalWrite(red2,LOW); digitalWrite(yellow2,HIGH); digitalWrite(blue2,LOW); delay(1000); //Yellow LED Delay digitalWrite(red1,LOW); digitalWrite(yellow1,LOW); digitalWrite(blue1,HIGH); digitalWrite(red2,HIGH); digitalWrite(yellow2,LOW); digitalWrite(blue2,LOW); delay(5000); //Blue LED Delay delay(5000); delay(5000); digitalWrite(red1,LOW); digitalWrite(yellow1,LOW); digitalWrite(blue1,LOW); digitalWrite(red2,LOW); digitalWrite(yellow2,LOW); digitalWrite(blue2,LOW); }