I've a school project "automatic railway system ", i wrote the code but it works only on protues . when i burn it on the kit it doesn't work . what is the wrong with this code ??
"my project idea is to make a railway train gate control.
1-when the train is coming make the buzzer on with 90 sec count down on 7-seg. then open the gate.
2- after the train leaving the station close the gate & the buzzer . i'm using 2 limit switches one for opening the gate & the other for closing it. and a dc motor to move the gate between position 0 & position 90. "
but i'm facing an error in seven_seg.c file : expected expression before '=' token in this line
PORTB=PORTB|BUZZER;
i tried to do this to see what happen if i make //PORTB=PORTB|BUZZER;
the same error still appears but on this lines in railway_control.c file
if((PINA & SWITCH1)==0b00000000)
PORTB=PORTB | MOTORR;
PORTB=PORTB & ~ BUZZER;
PORTB=PORTB & ~ MOTORR;
else if((PINA & SWITCH2)==0b00000000)
PORTB=PORTB & ~ MOTORL;
what identifiers missing before '=' ?
here is the code after i edited it
#include"avr/io.h"
#define F_CPU 16000000
#include"avr/delay.h"
#include"types.h"
#include"seven_seg.h"
void main (void)
{
DDRA=0b00000000;// define switches as input
PORTA=0b00000011;
DDRB=0b00000111;//define motor & buzzer as output
DDRD=0b11111111;/* using port d &port c for 7-seg*/
DDRC=0b11111111;
while (1)
{
if((PINA&SWITCH1)==0b00000000)
{
display();
PORTB=PORTB|MOTORR;
_delay_ms(3000);
PORTB=PORTB & ~ BUZZER;
PORTB=PORTB&~MOTORR;
_delay_ms(300);
}
else if((PINA&SWITCH2)==0b00000000)
{
PORTB=PORTB|MOTORL;
_delay_ms(3000);
PORTB=PORTB &~ MOTORL;
_delay_ms(300);
}
else
{
//Do Nothing
}
}
}
the seven_seg.c file
#include"avr\io.h"
#include"types.h"
#include"avr/delay.h"
s8 i,j;
s8 arr[10]={0b00111111,0b00000110,0b01011001,
0b01001111,0b01101100,0b01101101,0b01111101,
0b00000111,0b01111111,0b01101111};
void display(void)
{
PORTC=arr[9];
PORTD= arr[0];
PORTB=PORTB|BUZZER;
for(i=8;i>=0;i--)
{
PORTC=arr[i];
for(j=9;j>=0;j--)
{
PORTD=arr[j];
_delay_ms(100);
}
}
}
types.h file
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned long int u32;
typedef signed char s8;
typedef signed short int s16;
typedef signed long int s32;
typedef float f32;
typedef double f64;
#define BUZZER=0b00000100;
#define MOTORR=0b00000001;
#define MOTORL=0b00000010;
#define SWITCH1=0b00000001;
#define SWITCH2=0b00000010;
seven_seg.h file
#ifndef seven_SEG_H_
#define seven_SEG_H_
void display(void);
#endif /* seven_SEG_H_ */