|
|
View previous topic :: View next topic |
Author |
Message |
atai21
Joined: 30 Dec 2010 Posts: 31
|
traffic light code |
Posted: Sun Jul 10, 2011 10:44 pm |
|
|
dear all...i have construct a code for 4 way traffic light.please help me with the code
Code: |
#include <16F84.h>
#define R1 PIN_A0
#define Y1 PIN_A1
#define G1 PIN_A2
#define R2 PIN_A3
#define Y2 PIN_A4
#define G2 PIN_B1
#define R3 PIN_B2
#define Y3 PIN_B3
#define G3 PIN_B4
#define R4 PIN_B5
#define Y4 PIN_B6
#define G4 PIN_B7
void main ()
while (1)
{
output_high (R1);
output_low (Y1);
output_low (G1);
delay_ms (1000);
output_high (Y1);
output_low (R1);
output_low (G1);
delay_ms (1000);
output_high (G1);
output_low (Y1);
output_low (R1);
delay_ms (1000);
output_high (R2);
output_low (Y2);
output_low (G2);
delay_ms (1000);
output_high (Y2);
output_low (R2);
output_low (G2);
delay_ms (1000);
output_high (G2);
output_low (Y2);
output_low (R2);
delay_ms (1000);
output_high (R3);
output_low (Y3);
output_low (G3);
delay_ms (1000);
output_high (Y3);
output_low (R3);
output_low (G3);
delay_ms (1000);
output_high (G3);
output_low (Y3);
output_low (R3);
delay_ms (1000);
output_high (G4);
output_low (Y4);
output_low (R4);
delay_ms (1000);
output_high (Y4);
output_low (R4);
output_low (G4);
delay_ms (1000);
output_high (R4);
output_low (Y4);
output_low (G4);
delay_ms (1000);
}
|
it gives an error like this:
Code: | Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FM "main.c" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 29 "main.c" Line 19(7,12): Function definition different from previous definition main Param#1
*** Error 43 "main.c" Line 19(8,9): Expecting a declaration
*** Error 43 "main.c" Line 19(9,10): Expecting a declaration
*** Error 43 "main.c" Line 20(1,2): Expecting a declaration
*** Error 28 "main.c" Line 21(16,17): Expecting an identifier
*** Error 43 "main.c" Line 21(17,18): Expecting a declaration
*** Error 28 "main.c" Line 22(15,16): Expecting an identifier
*** Error 43 "main.c" Line 22(16,17): Expecting a declaration
*** Error 28 "main.c" Line 23(15,16): Expecting an identifier
*** Error 43 "main.c" Line 23(16,17): Expecting a declaration
*** Error 28 "main.c" Line 24(11,15): Expecting an identifier
*** Error 43 "main.c" Line 24(16,17): Expecting a declaration
*** Error 28 "main.c" Line 25(16,17): Expecting an identifier
*** Error 43 "main.c" Line 25(17,18): Expecting a declaration
*** Error 28 "main.c" Line 26(15,16): Expecting an identifier
*** Error 43 "main.c" Line 26(16,17): Expecting a declaration
*** Error 28 "main.c" Line 27(15,16): Expecting an identifier
*** Error 43 "main.c" Line 27(16,17): Expecting a declaration
*** Error 28 "main.c" Line 28(11,15): Expecting an identifier
*** Error 43 "main.c" Line 28(16,17): Expecting a declaration
*** Error 28 "main.c" Line 29(16,17): Expecting an identifier
*** Error 43 "main.c" Line 29(17,18): Expecting a declaration
*** Error 28 "main.c" Line 30(15,16): Expecting an identifier
*** Error 43 "main.c" Line 30(16,17): Expecting a declaration
*** Error 28 "main.c" Line 31(15,16): Expecting an identifier
*** Error 43 "main.c" Line 31(16,17): Expecting a declaration
*** Error 28 "main.c" Line 32(11,15): Expecting an identifier
*** Error 43 "main.c" Line 32(16,17): Expecting a declaration
*** Error 28 "main.c" Line 34(16,17): Expecting an identifier
*** Error 43 "main.c" Line 34(17,18): Expecting a declaration
*** Error 28 "main.c" Line 35(15,16): Expecting an identifier
*** Error 43 "main.c" Line 35(16,17): Expecting a declaration
*** Error 28 "main.c" Line 36(15,16): Expecting an identifier
*** Error 43 "main.c" Line 36(16,17): Expecting a declaration
*** Error 28 "main.c" Line 37(11,15): Expecting an identifier
*** Error 43 "main.c" Line 37(16,17): Expecting a declaration
*** Error 28 "main.c" Line 38(16,17): Expecting an identifier
*** Error 43 "main.c" Line 38(17,18): Expecting a declaration
*** Error 28 "main.c" Line 39(15,16): Expecting an identifier
*** Error 43 "main.c" Line 39(16,17): Expecting a declaration
*** Error 28 "main.c" Line 40(15,16): Expecting an identifier
*** Error 43 "main.c" Line 40(16,17): Expecting a declaration
*** Error 28 "main.c" Line 41(11,15): Expecting an identifier
*** Error 43 "main.c" Line 41(16,17): Expecting a declaration
*** Error 28 "main.c" Line 42(16,17): Expecting an identifier
*** Error 43 "main.c" Line 42(17,18): Expecting a declaration
*** Error 28 "main.c" Line 43(15,16): Expecting an identifier
*** Error 43 "main.c" Line 43(16,17): Expecting a declaration
*** Error 28 "main.c" Line 44(15,16): Expecting an identifier
*** Error 43 "main.c" Line 44(16,17): Expecting a declaration
*** Error 28 "main.c" Line 45(11,15): Expecting an identifier
*** Error 43 "main.c" Line 45(16,17): Expecting a declaration
*** Error 28 "main.c" Line 47(16,17): Expecting an identifier
*** Error 43 "main.c" Line 47(17,18): Expecting a declaration
*** Error 28 "main.c" Line 48(15,16): Expecting an identifier
*** Error 43 "main.c" Line 48(16,17): Expecting a declaration
*** Error 28 "main.c" Line 49(15,16): Expecting an identifier
*** Error 43 "main.c" Line 49(16,17): Expecting a declaration
*** Error 28 "main.c" Line 50(11,15): Expecting an identifier
*** Error 43 "main.c" Line 50(16,17): Expecting a declaration
*** Error 28 "main.c" Line 51(16,17): Expecting an identifier
*** Error 43 "main.c" Line 51(17,18): Expecting a declaration
*** Error 28 "main.c" Line 52(15,16): Expecting an identifier
*** Error 43 "main.c" Line 52(16,17): Expecting a declaration
*** Error 28 "main.c" Line 53(15,16): Expecting an identifier
*** Error 43 "main.c" Line 53(16,17): Expecting a declaration
*** Error 28 "main.c" Line 54(11,15): Expecting an identifier
*** Error 43 "main.c" Line 54(16,17): Expecting a declaration
*** Error 28 "main.c" Line 55(16,17): Expecting an identifier
*** Error 43 "main.c" Line 55(17,18): Expecting a declaration
*** Error 28 "main.c" Line 56(15,16): Expecting an identifier
*** Error 43 "main.c" Line 56(16,17): Expecting a declaration
*** Error 28 "main.c" Line 57(15,16): Expecting an identifier
*** Error 43 "main.c" Line 57(16,17): Expecting a declaration
*** Error 28 "main.c" Line 58(11,15): Expecting an identifier
*** Error 43 "main.c" Line 58(16,17): Expecting a declaration
*** Error 28 "main.c" Line 60(16,17): Expecting an identifier
*** Error 43 "main.c" Line 60(17,18): Expecting a declaration
*** Error 28 "main.c" Line 61(15,16): Expecting an identifier
*** Error 43 "main.c" Line 61(16,17): Expecting a declaration
*** Error 28 "main.c" Line 62(15,16): Expecting an identifier
*** Error 43 "main.c" Line 62(16,17): Expecting a declaration
*** Error 28 "main.c" Line 63(11,15): Expecting an identifier
*** Error 43 "main.c" Line 63(16,17): Expecting a declaration
*** Error 28 "main.c" Line 64(16,17): Expecting an identifier
*** Error 43 "main.c" Line 64(17,18): Expecting a declaration
*** Error 28 "main.c" Line 65(15,16): Expecting an identifier
*** Error 43 "main.c" Line 65(16,17): Expecting a declaration
*** Error 28 "main.c" Line 66(15,16): Expecting an identifier
*** Error 43 "main.c" Line 66(16,17): Expecting a declaration
*** Error 28 "main.c" Line 67(11,15): Expecting an identifier
*** Error 43 "main.c" Line 67(16,17): Expecting a declaration
*** Error 28 "main.c" Line 68(16,17): Expecting an identifier
*** Error 43 "main.c" Line 68(17,18): Expecting a declaration
*** Error 28 "main.c" Line 69(15,16): Expecting an identifier
*** Error 43 "main.c" Line 69(16,17): Expecting a declaration
*** Error 28 "main.c" Line 70(15,16): Expecting an identifier
*** Error 43 "main.c" Line 70(16,17): Expecting a declaration
*** Error 28 "main.c" Line 71(11,15): Expecting an identifier
*** Error 43 "main.c" Line 71(16,17): Expecting a declaration
100 Errors, 0 Warnings.
|
tq for your help |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Mon Jul 11, 2011 8:11 am |
|
|
Quote: |
void main ()
while (1)
{
output_high (R1);
o |
void main () {
while (1)
{
output_high (R1);
o _________________ David |
|
|
atai21
Joined: 30 Dec 2010 Posts: 31
|
|
Posted: Mon Jul 11, 2011 6:58 pm |
|
|
tq its already solved but when i try on PIC its not working...no lamp are on |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jul 11, 2011 8:00 pm |
|
|
What value of resistors do you have to limit the LED currents ?
PIC pin ---A-|>|-K--/\/\/\/\---- gnd. |
|
|
atai21
Joined: 30 Dec 2010 Posts: 31
|
|
Posted: Mon Jul 11, 2011 8:03 pm |
|
|
i use 150Ohm resistor.should i try another resistor? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jul 11, 2011 8:13 pm |
|
|
I'd probably use 330R resistors. |
|
|
atai21
Joined: 30 Dec 2010 Posts: 31
|
|
Posted: Tue Jul 12, 2011 12:59 am |
|
|
May I know what is the other problem of my code because only 1 LED is on and the others not. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Jul 12, 2011 8:45 am |
|
|
Hi,
This is a simple project, and with the circuit right in front of you, aren't you in the best position to find the problem yourself? At the very least, provide some basic diagnostic info to the forum to give us something to go on.
Earlier it was assumed that your "lamps" were really LED's. Is that true? If so, are they all connected the same way? Can you try a very simple version of your code that flashes a single LED in a loop? Can you try another simple program that lights a different LED? When the LED is supposed to be ON, can you measure a 'high' output value on the PIC output pin? Perhaps you have damaged your PIC by not using current limiting resistors initially? Can you try another PIC?
Finally, you never posted your Fuses, or your compiler version. It's possible that you PIC is not even running correctly. If you post a complete program we can try it out!
John |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|