How to upload the code
Hey everyone š Iām trying to upload code from my phone using the ArduinoDroid app, but I keep getting this error:
Error: Can't open connection to MCU.
Consider switching to Avrdude uploader (ā® / Settings / App settings / Uploader) or follow troubleshooting (ā® / Help / Troubleshooting)
I already switched to Avrdude uploader, allowed USB permissions, and my board powers up (LED is on), but it still fails to upload.
š§ My setup:
Arduino [Uno/Nano ā (mention your exact one)]
Connected via OTG cable to my Android phone
Using ArduinoDroid app
š” What Iām trying to do: Iām making an NRF24L01 wireless test project ā one Arduino has a push button (transmitter) and the other has a buzzer (receiver). When I press the button, the buzzer should beep using wireless communication.
The code compiles fine, but the upload fails with the connection error above.
Any idea how to fix this or what settings to check in ArduinoDroid? š
Transmiter code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
int buttonPin = 2;
bool buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT); // using external 10k pull-down resistor
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
buttonState = digitalRead(buttonPin);
radio.write(&buttonState, sizeof(buttonState));
delay(10);
}
Reciver code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
int buzzer = 3;
bool buttonState = 0;
void setup() {
pinMode(buzzer, OUTPUT);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
if (radio.available()) {
radio.read(&buttonState, sizeof(buttonState));
digitalWrite(buzzer, buttonState ? HIGH : LOW);
}
}
0 Replies