Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: October 14, 2012, 07:46:26 am » |
Hola he estado programando el arduino metiendo los ejemplos correctamente pero cuando me he puedo ha intentar hacer algo con arduino y la roomba este me ha dejado de funcionar y ahora al subir un nuevo sketch me da un error avrdude stk500_getsync() not in sync resp=0x00 y no puedo hacer nada. Necesito ayuda
Este es el codigo que inserte
int rxPin = 0; int txPin = 1; int ddPin = 2; int ledPin = 13; char sensorbytes[10];
#define bumpright (sensorbytes[0] & 0x01) #define bumpleft (sensorbytes[0] & 0x02)
void setup() { // pinMode(txPin, OUTPUT); pinMode(ddPin, OUTPUT); // sets the pins as output pinMode(ledPin, OUTPUT); // sets the pins as output Serial.begin(57600);
digitalWrite(ledPin, HIGH); // say we're alive
// wake up the robot digitalWrite(ddPin, HIGH); delay(100); digitalWrite(ddPin, LOW); delay(500); digitalWrite(ddPin, HIGH); delay(2000); // set up ROI to receive commands Serial.write(128); // START delay(50); Serial.write(130); // CONTROL delay(50); digitalWrite(ledPin, LOW); // say we've finished setup }
void loop() { digitalWrite(ledPin, HIGH); // say we're starting loop updateSensors(); digitalWrite(ledPin, LOW); // say we're after updateSensors if(bumpleft) { spinRight(); delay(1000); } else if(bumpright) { spinLeft(); delay(1000); } goForward(); } void goForward() { char c[] = { 137, 0x00, 0xc8, 0x80, 0x00 }; // 0x00c8 == 200 Serial.write( c ); } void goBackward() { char c[] = { 137, 0xff, 0x38, 0x80, 0x00 }; // 0xff38 == -200 Serial.write( c ); } void spinLeft() { char c[] = { 137, 0x00, 0xc8, 0x00, 0x01 }; Serial.write( c ); } void spinRight() { char c[] = { 137, 0x00, 0xc8, 0xff, 0xff }; Serial.write( c ); } void updateSensors() { Serial.write(142); Serial.write(1); // sensor packet 1, 10 bytes delay(100); // wait for sensors char i = 0; while(Serial.available()) { int c = Serial.read(); if( c==-1 ) { for( int i=0; i<5; i ++ ) { // say we had an error via the LED digitalWrite(ledPin, HIGH); delay(50); digitalWrite(ledPin, LOW); delay(50); } } sensorbytes[i++] = c; } }
|