Timeout upon uploading

It keeps saying timeout


Sketch uses 12570 bytes (4%) of program storage space. Maximum is 253952 bytes.
Global variables use 494 bytes (6%) of dynamic memory, leaving 7698 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
Failed uploading: uploading error: exit status 1

I've already installed CH340 and tried to upload from two computers. I dont know whats wrong..

#include <BlynkSimpleSerialBLE.h>  // Include the Blynk library
#include <SoftwareSerial.h>       // Include the software serial library for HC-05

char auth[] = "hY8qB9qHO_jVSiF2kU1R5B40GiO_H-E6";  // Your Blynk auth token

SoftwareSerial SerialBLE(10, 11);  // RX, TX pins for HC-05

int leds[] = {22, 26, 30, 34, 38, 42, 46};  // Array of LED pins
int buzzers[] = {31, 35};              // Array of buzzer pins
int pushButton = 13;                 // Push button pin

int medicineTimes[] = {0, 0, 0, 0, 0, 0, 0};  // Array to store medicine times
bool isActive[] = {false, false, false, false, false, false, false};  // Array to track reminder activation

void setup() {
  for (int i = 0; i < 7; i++) {
    pinMode(leds[i], OUTPUT);  // Set LED pins as OUTPUT
  }
  
  for (int i = 0; i < 2; i++) {
    pinMode(buzzers[i], OUTPUT);  // Set buzzer pins as OUTPUT
  }
  
  pinMode(pushButton, INPUT);  // Set push button pin as INPUT
  
  Serial.begin(9600);          // Start serial communication
  SerialBLE.begin(9600);       // Start software serial communication for HC-05
  
  Blynk.begin(SerialBLE, auth);  // Initialize Blynk
}

void loop() {
  Blynk.run();  // Run Blynk
  
  for (int i = 0; i < 7; i++) {
    if (medicineTimes[i] > 0 && !isActive[i]) {
      if (millis() > medicineTimes[i]) {
        activateReminder(i);  // Activate reminder for the corresponding LED if medicine time is reached
        isActive[i] = true;   // Set the reminder as active
      }
    }
  }
  
  if (digitalRead(pushButton) == HIGH) {
    resetReminder();  // Reset reminder when push button is pressed
  }
}

void activateReminder(int index) {
  digitalWrite(leds[index], HIGH);  // Turn on the corresponding LED
  for (int i = 0; i < 2; i++) {
    tone(buzzers[i], 1000);  // Play a tone on each buzzer
  }
}

void resetReminder() {
  for (int i = 0; i < 7; i++) {
    digitalWrite(leds[i], LOW);  // Turn off all LEDs
    isActive[i] = false;         // Set all reminders as inactive
  }
  
  for (int i = 0; i < 2; i++) {
    noTone(buzzers[i]);  // Stop the tone on each buzzer
  }
}

BLYNK_WRITE(V0) {
  medicineTimes[0] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 1
}

BLYNK_WRITE(V1) {
  medicineTimes[1] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 2
}

BLYNK_WRITE(V2) {
  medicineTimes[2] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 3
}

BLYNK_WRITE(V3) {
  medicineTimes[3] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 4
}

BLYNK_WRITE(V4) {
  medicineTimes[4] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 5
}

BLYNK_WRITE(V5) {
  medicineTimes[5] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 6
}

BLYNK_WRITE(V6) {
  medicineTimes[6] = param.asLong() * 1000;  // Get medicine time from Blynk app in seconds for LED 7
}

Using HC-05, Arduino Mega 2560, and 7 LEDs with 2 Buzzers. Trying to make an auto medicine-taking reminder using the Blynk IOT app as virtual widgets to set the specific time reminders. LED and Buzzer will sound off upon the time set. One time widget is for one LED. A total of 7 associations. Please help ...

Something on pins 0 and 1, like HC-05? Disconnect it before upload.
BTW, sketch has nothing with a upload error if it fits into memory.

Do I just unplug the HC-05 before upload?

Yes.

Thank you so much brotherrr

Do I just connect the HC-05 back upon uploading to pair it with the Blynk IOT app?

The upload process uses Tx,Rx it means pins 0,1. You cannot use them for anything else until the upload is complete. Discomfort? Sure. However Mega 2560 has another 3 HW serial lines. Consider to use one of them.

Are you referring to the 3HW serial lines to the other 3 sets of TX and RX communication pins?
So using TX314 and RX315 won't affect the upload? Must i change my code since the connections are different now?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.