| 
 | 
 
各位前輩高手,小弟剛接觸arduino 版,最近使用arduino mega 2560搭配L293D與藍芽HC-06,想嘗試寫個藍芽控制伺服馬達與DC馬達動作, 
驗證時沒有問題,但上傳到版子上時,有時會出現下列錯誤訊息: 
 
avrdude: stk500v2_recv(): checksum error 
avrdude: verification error, first mismatch at byte 0x0018 
         0xfc != 0x3c 
avrdude: verification error; content mismatch 
 
且  0xfc != 0x3c會有變化 
 
 
以下為程式碼 
==================== 
#include <SoftwareSerial.h> 
#include <Servo.h> 
#include <AFMotor.h> 
 
#define SERVO1_PWM 10  
 
SoftwareSerial BTSerial(10, 11); // RX, TX 
int pp;   //temp value 
 
AF_DCMotor motor(1,MOTOR12_2KHZ); 
Servo servo; 
 
void setup() { 
  // put your setup code here, to run once: 
 Serial.begin(9600); 
 BTSerial.begin(9600);    //BTSerial 9600,19200,38400,57600 
 servo.attach(SERVO1_PWM); 
 motor.run(RELEASE);  
} 
 
void loop() { 
  // put your main code here, to run repeatedly: 
 if (BTSerial.available()>0){ 
    pp=BTSerial.read(); 
    Serial.println(pp); 
    switch(pp){ 
    case 'f':  //Forward 
      Up(); 
    break; 
    case 'b':  //Back 
      Down(); 
    break; 
    case 'l':  //Turn Left 
      Left(); 
    break; 
    case 'r':  //Turn Right 
      Right(); 
    break; 
    case 's':  //Stop 
      stop(); 
    break; 
    } 
  } 
} 
int Up(){ 
  servo.write(0); 
  motor.setSpeed(200); 
  motor.run(FORWARD); 
   
  //delay(1000); 
} 
int Down(){ 
   servo.write(0); 
   motor.setSpeed(200); 
   motor.run(BACKWARD); 
} 
int Right(){ 
   servo.write(45); 
} 
int Left(){ 
   servo.write(135); 
} 
int stop(){ 
    motor.run(RELEASE); 
} 
=============================== 
程式結束 
 
麻煩前輩高手們,是否可以幫我看看,是哪邊出了問題,因小弟剛接觸不久,很多異警訊息都看不太懂。 
麻煩前輩高手了,謝謝。 |   
 
 
 
 |