#include <mega8.h> #include <delay.h> #define pinWrite(i,j,port)port=(i)?port|(1<<j):port&(~(1<<j)) #define pinPulse(j,port)port|=(1<<j)\ port&=(~(1<<j)) #define sport PORTB #define sclock PORTB1 #define slatch PORTB2 #define sdata PORTB0 uint8_t j,i=0,a[]={255, 255, 193, 221, 221, 255, 255, 255}; void dshift(uint8_t data) { for(uint8_t i=0;i<8;i++) { if(data & 0b10000000) { pinWrite(1,sdata,sport); } else { pinWrite(0,sdata,sport); } pinPulse(sclock,sport); data=data<<1; //Now bring next bit at MSB position } pinPulse(slatch,sport); } void main(void) { // Input/Output Ports initialization // Port B initialization // Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out DDRB=(1<<DDB7) | (1<<DDB6) | (1<<DDB5) | (1<<DDB4) | (1<<DDB3) | (1<<DDB2) | (1<<DDB1) | (1<<DDB0); // State: Bit7=0 Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0 PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0); // Port C initialization // Function: Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out DDRC=(1<<DDC6) | (1<<DDC5) | (1<<DDC4) | (1<<DDC3) | (1<<DDC2) | (1<<DDC1) | (1<<DDC0); // State: Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0 PORTC=(0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0); // Port D initialization // Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out DDRD=(1<<DDD7) | (1<<DDD6) | (1<<DDD5) | (1<<DDD4) | (1<<DDD3) | (1<<DDD2) | (1<<DDD1) | (1<<DDD0); // State: Bit7=0 Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0 PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0); while (1) { for(i=0;i<8;i++) { j=a[i]; dshift(j); pinPulse(PORTB4,PORTB); } } }
The above code gives the error
Error: C:\Users\deepa\Desktop\matrix\ledm.c(12): '(' expected
When I convert the first uint8_t to int, it gives even more errors:
Error: C:\Users\deepa\Desktop\matrix\ledm.c(13): declaration syntax error
Error: C:\Users\deepa\Desktop\matrix\ledm.c(15): ')' expected, but ';' found
Error: C:\Users\deepa\Desktop\matrix\ledm.c(15): ';' expected, but ')' found
Error: C:\Users\deepa\Desktop\matrix\ledm.c(28): ';' expected
Error: C:\Users\deepa\Desktop\matrix\ledm.c(29): operand types 'int (*)()' and 'int' are incompatible with the '<<' or '<<=' operator
Error: C:\Users\deepa\Desktop\matrix\ledm.c(34): ';' expected
Error: C:\Users\deepa\Desktop\matrix\ledm.c(137): too many arguments in function call
Error: C:\Users\deepa\Desktop\matrix\ledm.c(138): ';' expected
I am just a beginner, so sorry for any mistakes i might have made.