Micro controller programming: Making a set of traffic lights

 by unknowndomain
Featured
breadboard.jpg
So you wana learn how to programme a micro controller?

This tutorial has been designed as a next step, following the fantastic tutorial 'Ghetto Programming: Getting started with AVR microprocessor on the cheap.' by The Real Elliot link you should read this before progressing onto this next step.

Today my friends we are going to make a pelican crossing using an Ateml ATTiny2313. This is probably more common in the UK but a pelican crossing allows pedestrians to stop road traffic and cross in a safe manner.

At the end of this project you might like to mess about with the code and get the lights to sequence for your countries equivalent system, or for a junction like a cross roads (intersection).
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

Ok if you are continuing this project after completing the Ghetto Programming instructable you will need to order a few extra parts. I have a list below which will detail every thing you need for this project. However if you already have the parts (Micro controller, LEDs etc..) then just leave these out. For clarity I have given the part numbers which you can use to order them directly from Rapid Online the company from which I ordered mine.

These are minimum requirements you could order more for backup or expansion of this project.

1x ATTiny2313-20PU (73-4316)
1x 20 pin socket (22-0170)
1x Parallel port plug (15-0510)
1x Breadboard (34-0655)
1x Jumper Links (34-0495)
2x Red Led's (55-0155)
1x Orange (not amber) Led (55-0124)
2x Green Led's (55-0120)
1x White Led *(55-1640)
1x Electronic Buzzer (35-0072)
1x Push to make button (78-0350)
3x 1K Resistors (62-0370)
6x 150ohm Resistors (62-0350)
5x Head Plug (22-0515)
2x Head Socket (22-5114)
1x Battery Box (18-3685)

Rapid Online

In total this came to £17.18 ex vat (approx $35.42) however you might find it cheaper else where but I doubt it.

Rapid Online offers free shipping when you spend over £5 it might be worth looking about for a few goodies and upping the led's and chips for backup if you intend to explore microchip programming further.

As well as the above parts you will need some basic stuff which you may already have...

Wire (probably about 0.5mm stranded wire)
Solder (around 22swg lead free stuff)

You will also need these tools...

Soldering Iron + Stand + Sponge
Solder Sucker/Pump
Side Cutters
Wire Strippers

Once you have all the parts you are ready to assemble your project.
lpravasi says: Oct 22, 2011. 2:46 AM
hi..i m making the traffic lights project using the 8051 micocontroller..can u help me with the assembly language program code for this project.:)
monu.4750 in reply to lpravasiOct 27, 2012. 11:58 PM
i have made this project.
you can contact me at mukesh_9134@yahoo.in
dakajohnc in reply to lpravasiNov 26, 2011. 1:05 AM
hi.. i happen to be doing the same project but as my assignment..iam asking for the codes for the 8051...dakajohnc2@gmail.com.thanx
dsnggada says: Nov 11, 2011. 1:27 PM
i just started microcontroller course. any of u help me with a material for beginners? please, i will really appreciate it. thank u.
fostersfriend says: Jan 2, 2011. 9:57 PM
Jameco.com is the cheapest
satadru says: May 28, 2010. 4:19 AM
thnx for helping ..My question is that can i use usb port (serial) instead of parallal  port ?
penester says: Dec 21, 2009. 3:27 AM
Oh ! Thank you very much ;-D
chooseausername says: Jul 26, 2007. 6:26 AM
Technically, it's not a microprocessor, but a microcontroller ;-) And about the traffic lights, that's weird. I thought the protocole was the same in every countries of the european union, i mean : - red goes directly to green (no orange) - green goes orange - orange geos red (red -> green ; green -> orange -> red ) Is it really different ( red -> orange -> green ; green -> orange -> red ) in UK ??
Berserk87 in reply to chooseausernameApr 1, 2009. 1:55 AM
i thought that as well, haha. i was looking at it thinking "this was featured, and he didnt even get the traffic pattern right....." didnt realize it was different other places.
Derin in reply to chooseausernameJul 16, 2008. 11:45 PM
NOPE not that sequence here we go red,red+amber,green,flashing green,amber,red(same sequence as UK)
unknowndomain (author) in reply to chooseausernameJul 26, 2007. 11:53 AM
I have corrected all instances of microchip,microprocessor etc... to microcontroller just for you! Thanks for pointing that out. :D
chooseausername in reply to unknowndomainJul 26, 2007. 2:49 PM
Oh ! Thank you very much ;-D
APHawkes in reply to chooseausernameJul 26, 2007. 8:29 AM
FYI in the US it's yellow instead of orange. Same sequence, though.
Derin in reply to APHawkesJul 16, 2008. 11:44 PM
same here,yellow instead of amber
josh92176 in reply to chooseausernameJul 26, 2007. 7:48 AM
In the UK it is the same, you are right.As you said it probably is the same in all countries of the EU. i.e. red - green, green - orange - red
steven07 says: Jul 25, 2007. 11:21 PM
Nice tutorial your algorithm's really easy to follow. Traffic lights were one of my first projects using micro-controllers.
unknowndomain (author) in reply to steven07Jan 11, 2009. 3:36 AM
Glad you enjoyed it.
sweete says: Dec 17, 2008. 2:13 PM
Hi, please can u help me with de code in c in trafic ligths using 8051 microntroller and 7 segment displayand the trafic light module, please thank you very muchhhh
unknowndomain (author) in reply to sweeteDec 17, 2008. 3:06 PM
What is de coding? and are u just a bot?
leztat says: Oct 1, 2008. 10:52 AM
wow! nice project
wee_man says: Aug 3, 2008. 2:29 AM
Cool im getting started into programming and im just reading these to learn

but heres and idea make it like this


when the train comes close to the crossing somehow the train useing a microconntroller slows down and the crossing uses motors or something finds out that the train is coming up and plays the better and closes the arms would be a fun build

what do you think
unknowndomain (author) in reply to wee_manAug 6, 2008. 11:27 AM
Yeah its a good idea you would need to use a sensor and some motors but I am about to release a new article for Arduino of the same project, perhaps thats a better place to start as its far simpler code wise.
wee_man in reply to unknowndomainAug 6, 2008. 8:48 PM
yea another fun idea would be to get a rc helicopter or make one and have sensors on the bottem so when its low it goes higher and when its too high it goes down in the sence hovering unmanned unpiolted small size helicopter?
beardy says: Jul 28, 2007. 8:30 PM
Hang on a second, in the UK we're doing...

red, red & amber, green, amber, red. — right?

Since my train-set days I dreamed of making traffic lights but couldn't conceive of how... since getting to Arduino..!! oh yeah! It's the business.
Derin in reply to beardyJul 16, 2008. 11:42 PM
thats the same sequence where I live
spagettisticks says: Jul 30, 2007. 3:34 PM
(removed by author or community request)
unknowndomain (author) in reply to spagettisticksJul 30, 2007. 4:17 PM
Thanks for that I don't drive and I tried to do it from mine and my families memory. To be honest its not that important its about the programming but thanks perhapse I will get around to editing it.
unknowndomain (author) says: Jul 26, 2007. 11:10 AM
Thanks for the feedback the light sequence may be wrong although I did try to ensure it was correct. However as a point of notice there are different sequences for different systems in the UK normal traffic lights follow a Red - red & amber - green sequence where as pelican crossings follow a red - red and flashing amber and green sequence. I tried to make the project adaptable for different situations as UK citizens may be aware some times the crossing beeps some times its a continuous sound
chooseausername in reply to unknowndomainJul 26, 2007. 3:09 PM
No, actually it seems correct.

That's interresting. I was not aware there was a 4 states sequence used in various countries. And contrary to what i tought, it's not the same in all countries of the EU ...

"Red + Yellow/Amber/Orange" == "prepare your engine" :-)
Chavez says: Jul 25, 2007. 9:32 PM
(removed by author or community request)
rerat in reply to ChavezJul 26, 2007. 1:12 AM
You sure can hold a grudge. An entirely childish and needless grudge, might I add.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!