I think LEDs are VERY interesting. I wated to possibly add some LED traffic lights to my lego city, so I wanted to check out how I would make it; Im glad I did! I think that this system works amazingly! I am very happy with how it turned out. I didn't have my Arduino Uno on me, so I used the arduino HERO board from inventr.io. IT works the exact same.
The code and wiring are provided below! These traffic lights can be used for anything too! I learned quite a few new things, and im sure beginners will too. Thanks for looking at my project!
Step 1 Wiring:Make sure you use a 220 Ohm Resistor
Step 2 Coding:
So the next part is coding it! I'll explain the code, but it's very simple, which is why it's a beginner project!
So at the beginning of the code, we define every LED. Each LED is connected to a pin on our Arduino Uno. This lets the code know what each pin is, and its name.
So then we declare the LEDs as outputs.
Finally, this goes on forever.
So when we turn on our Arduino, it turns on the green LED, waits 10 seconds, turns it off, waits.2 seconds, turns on the yellow LED, waits 4 seconds, turns off the yellow LED, waits.2 seconds, turns on the red LED, waits 10 seconds, turns off the red LED and the whole process starts over.









_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)



Comments