Problem 1 mit Snake-Vision
Hi
Ich habe die snake erweiterung jetzt zu sammen gebastelt nur habe ich ein kleines problem mit der Programmierung habe schon paar mal drüber geschaut aber der sagt mir immer etwas vom Token wo keiner ist und laut buch keiner hin soll
Hier mal der Code
Code:
#include "asuro.h"
#define THRESH1 20
#define THRESH2 80
#define THRESH3 200
void ThermalData (unsigned int *data) {
ADMUX = (1 << REFS0) | (1 << REFS1) | IR_LEFT;
ADCSRA |= (1 << ADSC);
while (!(ADCSRA & (1 << ADIF)));
ADCSRA |= (1 << ADIF);
data[0] = ADCL + (ADCH) << 8);
ADMUX = (1 << REFS0) | (1 << REFS1) | IR_RIGHT;
ADCSRA |= (1 << ADSC);
while (!(ADCSRA & (1 << ADIF)));
ADCSRA |= (1 << ADIF);
data[1] = ADCL + (ADCH) << 8);
}
int main(void)
{
unsigned int tdata[2];
unsigned int speed;
signed int diff,sum;
Init();
MotorDir(FWD,FWD);
while(1);
{
ThermalData(tdata);
sum=tdata[0]+tdata[1];
if (sum>THRESH1) {
StatusLED(GREEN);
speed=140;
}
if (sum>THRESH2) {
StatusLED(YELLOW);
speed=200;
}
if (sum>THRESH3) {
StatusLED(RED);
speed=255;
}
diff=((signed)tdata[0]-(signed)tdata[1])*32/sum;
if (diff>4) {
BackLED(ON,OFF);
MotorSpeed(0,speed);
}
else if (diff<-4) {
BackLED(OFF,ON);
MotorSpeed(speed,0);
}
else {
BackLED(OFF,OFF);
MotorSpeed(speed,speed);
}
}
else {
StatusLED(OFF);
BackLED(OFF,OFF);
MotorSpeed(0,0);
}
}
return 0;
}
Und Hier die Fehlermeldung
Code:
> "make.exe" all
set -e; avr-gcc -MM -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=asuro.lst -std=gnu99 asuro.c \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > asuro.d; \
[ -s asuro.d ] || rm -f asuro.d
set -e; avr-gcc -MM -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test_i2cmaster.lst -std=gnu99 test_i2cmaster.c \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > test_i2cmaster.d; \
[ -s test_i2cmaster.d ] || rm -f test_i2cmaster.d
-------- begin --------
avr-gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: test_i2cmaster.c
avr-gcc -c -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test_i2cmaster.lst -std=gnu99 test_i2cmaster.c -o test_i2cmaster.o
In file included from asuro.h:82,
from test_i2cmaster.c:1:
C:/WinAVR/avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete. Use <avr/interrupt.h>."
test_i2cmaster.c: In function `ThermalData':
test_i2cmaster.c:17: warning: suggest parentheses around + or - inside shift
test_i2cmaster.c:17: error: syntax error before ')' token
test_i2cmaster.c:27: warning: suggest parentheses around + or - inside shift
test_i2cmaster.c:27: error: syntax error before ')' token
test_i2cmaster.c: In function `main':
test_i2cmaster.c:71: error: syntax error before "else"
test_i2cmaster.c: At top level:
test_i2cmaster.c:76: error: syntax error before '}' token
test_i2cmaster.c:79:2: warning: no newline at end of file
make.exe: *** [test_i2cmaster.o] Error 1
> Process Exit Code: 2
> Time Taken: 00:02
Bitte um Hilfe
Edit: OK habe es gefunden habe es so geschrieben data[0] = ADCL + (ADCH) << 8);
muss haber data[0] = ADCL + (ADCH << 8); so sein habe hinter der 8 ein ) das nicht dahin gehört