Problems uploading


#1

I cannot upload my mblock programs to the arduino board. It happens with all the programs that I’ve tried. Mblock is connected and mLink2 open. I cannot undestand what the problem is. The message that appears says Failed to compile file code.cpp

Arduino compile fail

Arduino server disconnected.

The whole message:
It appears: Command failed: avr-toolchain/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I"/app/src/external/arduino/avr-library/variants/standard" -I"/root/mblock-avr/temp/build" -I"avr-library/cores/arduino" -I"arduino-libraries/makeblock/src/" -I"arduino-libraries/makeblock/src/utility/avr/" -I"avr-library/libraries/Wire/src/utility/" -I"avr-library/libraries/Wire/src/" -I"avr-library/libraries/EEPROM/src/" -I"avr-library/libraries/SPI/src/" -I"avr-library/libraries/SoftwareSerial/src/" -I"arduino-libraries/arduino/WiFi/src/" -I"arduino-libraries/arduino/SD/src/" -I"arduino-libraries/arduino/Bridge/src/" -I"arduino-libraries/arduino/Temboo/src/" -I"arduino-libraries/arduino/Servo/src/" -I"arduino-libraries/arduino/Ethernet/src/" -I"arduino-libraries/arduino/TFT/src/" -I"arduino-libraries/arduino/SpacebrewYun/src/" -I"arduino-libraries/arduino/LiquidCrystal/src/" -I"arduino-libraries/arduino/GSM/src/" “/root/mblock-avr/temp/build/code.cpp” -o “/root/mblock-avr/temp/build/code.o” /root/mblock-avr/temp/build/code.cpp:15:7: error: conflicting declaration ‘float A0’ float A0 = 0; ^~ In file included from avr-library/cores/arduino/Arduino.h:257:0, from /root/mblock-avr/temp/build/code.cpp:1: /app/src/external/arduino/avr-library/variants/standard/pins_arduino.h:65:22: note: previous declaration as ‘const uint8_t A0’ static const uint8_t A0 = PIN_A0; ^~ /root/mblock-avr/temp/build/code.cpp: In function ‘void setup()’: /root/mblock-avr/temp/build/code.cpp:27:39: error: assignment of read-only variable ‘A0’ A0 = (1 + analogRead(A0+0) / 100); ^

Failed to compile file code.cpp

Arduino compile fail

Arduino server disconnected.


#2

What codes are you uploading and what arduino are you using?


#3

Arduino Uno.
My code (10 leds and 1 ldr so that less light in the room more leds turned on). But I have the same problem with all my programs. I’ve even tried to copy the C++ code in arduino online and it does not work either.


#4

The error message says that there is a conflicting declaration of the variable A0 in your code. The variable A0 is already defined as a constant in the Arduino library, but you are trying to assign a new value to it.

To resolve this issue, you need to choose a different variable name for your A0 variable. Here’s an example of how you can modify your code:

float myA0 = 0;

void setup() {
  myA0 = (1 + analogRead(A0 + 0) / 100);
  // Rest of your setup code
}

void loop() {
  // Your loop code
}

Basically, you just need to rename your variable.

After making this change, please try uploading your mBlock program to the Arduino board again to see if the issue is resolved.

Thanks!