Electronics > Projects, Designs, and Technical Stuff

Traffic light circuit with 556 timer: UPDATE!

(1/1)

phennessey:
Original thread: https://www.eevblog.com/forum/beginners/traffic-light-circuit-with-556-timer/

Well...after much ado, here's my first functioning traffic light circuit! I tried (and failed) to build this circuit with a 556 timer. I was only getting two LEDs to blink. Hopefully, SmokeyTheElectrician can weigh in on this. I think my schematic was wrong, despite being told it was correct. Perhaps someone can take a look at my old schematic?

https://www.eevblog.com/forum/beginners/traffic-light-circuit-with-556-timer/?action=dlattach;attach=895598;image

Since I just wanted to make the damn thing work, I used an Attiny85 for now. Here's the result:




--- Code: ---#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
while(1)
{
DDRB= 0xff; // set all pins to output
PORTB=0b00000001; // set pin 1 high
_delay_ms(3000); // delay 3 seconds
PORTB=0b00000010; // set pin 2 high
_delay_ms(1000); // delay 1 second
PORTB=0b00000100; // set pin 3 high
_delay_ms(3000); // delay 3 seconds
}
}
--- End code ---

Wimberleytech:
Excellent!

ebastler:
 :-+

And you have some pins to spare, so you could make a traffic light for both directions of an intersection. (With proper delays/safety times between the green phases for either side.) Or use one pin as an analog input to adjust the cycle time. Or cater to European tastes and implement a "red, red/yellow, green, yellow, ..." cycle. Or use two pins as a sensor input and a trigger output for a red-light camera. ;) 

Microcontrollers are neat; loads of flexiblity in small, simple and cheap packages.  :)

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod