PIC Traffic Lights

All that remains now is for the code to be `, compiled and converted to a HEX file that the PIC can understand. This is achieved easily with the PIC compiler that comes with the PICBASIC package. The PIC is programmed with any of the parallel or serial port programmers that are available free of charge from the NET. If you arrange the LEDs as the
PIC Traffic Lights - schematic

diagram of my prototype box, FIG 1, then the LEDs at the left of the PIC we will call LEDs A and to the right of the PIC LEDs B. Number them, starting at the top of LED A the RED LED number 0. The next one down is AMBER and is number 1. The bottom one GREEN is numbered 2. The right hand side LEDs starting from the top is numbered 4 for the top RED LED with number 5 being allocated for the middle, AMBER LED. The bottom, GREEN LED is number 6. Loop: Is the start of this programme. It is suitably called loop, as that is what the programme does. It loops continuously until it is switched off. It must be followed by the colon. HighO: Places a logicl on portB pinO consequently lighting LED 0. The colon is there to separate the first statement (high 0) from the next one in the same line. If the next statement (high 6) was placed on the next line down there would be no need for the colon. It just saves space. Pause1000 Is an instruction to tell the PIC to delay for 1 second. The actual time will depend on the clock frequency of the PIC. As a rule of thumb 1000 can be regarded as 1 second and 5000 as 5 seconds. The portB pins are placed in a register called bl. This could have been called b0, b2, b3 etc. there are, of course, only so many of these registers in each PIC. Lowbl instructs that everything in register b 1 goes to logic 0. In our case all the pins in portB, 0 to 7 are taken low. It does this in sequence from pin 0 to pin 7. Hence the reason for next bL If we had put `for b1= 0 to 3:next bl` then it would only place the portB pins 0, 1, 2 and 3 to a logic low. The first line of the `main` listing (high O:high6:pause5000) is placing RED LED A on and GREEN LED B on. It then stays on for about 5 seconds and then goes to the next stage. The RED A stays on AMBER is off AMBER B is on and GREEN A and GREEN ` B is off and so the sequence continues. The ` 0. 5-second pause on the last line is there to avoid errors at the return of the sequence. Fig. 2. The complete two-traffic lights circuit. Simple isn`t it! It will be obvious by looking at Fig. 2 that there is not much to the circuit. Perhaps series resistors of about 100 0 should be placed in between the ports and the LEDs to limit the current. The programming of the PIC is very simple but you will need the necessary software. PICBASIC is available from MAPLINS and the programmer software and circuit diagrams are available free of charge off the NET. You may know someone who already has both of these types of software. The PICBASIC available free on the NET is probably a good compiler, but is a bit more involved in that you have to type in some other information as well as your programme listing. It is not as `user friendly` as the PICBASIC programmer produced by Micro Engineering Labs Inc. I had no reply either from the NET PICBASIC people when I asked for some advice. If you do not have any means of programming or you prefer not to anyway, but would like a working set of traffic lights (you can remotely operate the LEDs) then I can supply you with a pre-programmed PIC. I can also produce a PCB and an 18-pin holder for the PIC. If anyone is interested I can just send the HEX code on receipt of a floppy disc and the return postage. The preprogrammed PICs I could supply at say £5 including P and P. the PCB and IC holder I could also send for £5 including P and P. The compiler then goes on to change rgis assembly language into hexadecimal code. I have not shown this as it appears as a block of letters and numbers and you cannot recognise any of the stages in it. List of components:- R1 4. K Resistor. 1 R2 R3 R4 470R. 2 # 4Mhz crystal. 1 C1 C2 22pf capacitor. 2 C3 0. 1 Mf. 1 LED1 Green LED. 1 LED2 Orange LED. 1 LED3 Red LED. 1 IC1 PIC 16C84. 1 PCB Pins. 2

Recommended videos

  • Populaire video
  • Density Based Traffic Signal System using Microcontroller
    Duration: 3:57.
  • Automatic Traffic Light Control System Using PIC Microcontroller
    Duration: 1:46.