Getting error while compiling if not nothing works: COM Port 4
My board AT Mega 2560 Arduino original chip
AtMega2560
16U-TH
355E3F
1935UJM
I bought an USB 2.0 powered board and sometime don't give me an USB error but program do not function at all? Led blink work perfectly on pin 13
The enclosed code works fine on a Arduino UNO
Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Sketch uses 1914 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
An error occurred while uploading the sketch
avrdude: ser_open(): can't open device "\.\COM4": Acc�s refus�.
avrdude: ser_drain(): read error: Descripteur non valide
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: Descripteur non valide
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Board Info included
/*
Motor Basics
Learn how to control one motor with the motor driver.
*/
//PIN VARIABLES
//the motor will be controlled by the motor A and B pins on the motor driver
const int AIN1 = 11; //control pin 1 on the motor driver for the right motor
const int AIN2 = 12; //control pin 2 on the motor driver for the right motor
const int PWMA = 13; //speed control pin on the motor driver for the right motor
const int BIN1 = 10; //control pin 1 on the motor driver for the Left motor
const int BIN2 = 9; //control pin 2 on the motor driver for the Left motor
const int PWMB = 8; //speed control pin on the motor driver for the Left motor
// VARIABLES
int motorSpeed = 0; //starting speed for the motor
void setup() {
//set the motor control pins as outputs
pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(BIN1, OUTPUT);
pinMode(BIN2, OUTPUT);
pinMode(PWMB, OUTPUT);
}
void loop() {
//drive motor forward (positive speed)
digitalWrite(AIN1, HIGH); //set pin 1 to high
digitalWrite(AIN2, LOW); //set pin 2 to low
analogWrite(PWMA, 250); //now that the motor direction is set, drive it at max speed
delay(3000);
digitalWrite(BIN1, HIGH); //set pin 1 to high
digitalWrite(BIN2, LOW); //set pin 2 to low
analogWrite(PWMB, 250); //now that the motor direction is set, drive it at max speed
delay(3000);
//drive motor backward (negative speed)
digitalWrite(AIN1, LOW); //set pin 1 to low
digitalWrite(AIN2, HIGH); //set pin 2 to high
analogWrite(PWMA, 250); //now that the motor direction is set, drive it at max speed
digitalWrite(BIN1, LOW); //set pin 1 to low
digitalWrite(BIN2, HIGH); //set pin 2 to high
analogWrite(PWMB, 250); //now that the motor direction is set, drive it at max speed
delay(3000);
//stop motor
digitalWrite(AIN1, LOW); //set pin 1 to low
digitalWrite(AIN2, LOW); //set pin 2 to low
analogWrite(PWMA, 0); //now that the motor direction is set, stop motor
digitalWrite(BIN1, LOW); //set pin 1 to low
digitalWrite(BIN2, LOW); //set pin 2 to low
analogWrite(PWMB, 0); //now that the motor direction is set, stop motor
delay(3000);
}
Any adsvices would be welcom
Thanks