Error message uploading sketch

the code verifies ok but I just get the error message cant upload; any suggestions?

Yes

Post the full error message and the code using code tags

`
Uploading: image.png…
``

const int sensorPin = A0;
const float baselineTemp = 20.0;

void setup() {
  Serial .begin (9600);
  for (int pinNumber =2;pinNumber < 5; pinNumber ++){
    pinMode (pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
    // put your setup code here, to run once:
  }

}

void loop() {
  int sensorVal=analogRead(sensorPin);
  Serial.print ("Sensor Value:");
  Serial.print(sensorVal);
  // convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0)*5.0;
  Serial.print (",Volts:");
  Serial.print (voltage);
  Serial.print ("degrees C:");
  //convert the votltage to temperature in degrees
  float temperature = (voltage - .5)*100;
  Serial.print (temperature);
  if (temperature< baselineTemp){
    digitalWrite(2,LOW);
    digitalWrite (3, LOW);
    digitalWrite (4,LOW);}
   else if (temperature>=baselineTemp+2&&  temperature < baselineTemp+4){
    digitalWrite (2,HIGH);
    digitalWrite (3,LOW);
    digitalWrite (4,LOW);
  }else if (temperature>=baselineTemp+6){
    digitalWrite (2,HIGH);
    digitalWrite (3, HIGH);
    digitalWrite (4,HIGH);
  }
  delay (1);
  }

Search the Forum.

Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"

Sketch uses 4030 bytes (12%) of program storage space. Maximum is 32256 bytes.

Global variables use 230 bytes (11%) of dynamic memory, leaving 1818 bytes for local variables. Maximum is 2048 bytes.

An error occurred while uploading the sketch



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Nick Savage\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Nick Savage\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Nick Savage\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0042 -ide-version=10819 -build-path C:\Users\NICKSA~1\AppData\Local\Temp\arduino_build_354036 -warnings=none -build-cache C:\Users\NICKSA~1\AppData\Local\Temp\arduino_cache_348792 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\Nick Savage\Documents\Arduino\project_book2\project_book2.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Nick Savage\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Nick Savage\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Nick Savage\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0042 -ide-version=10819 -build-path C:\Users\NICKSA~1\AppData\Local\Temp\arduino_build_354036 -warnings=none -build-cache C:\Users\NICKSA~1\AppData\Local\Temp\arduino_cache_348792 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\Nick Savage\Documents\Arduino\project_book2\project_book2.ino

Using board 'uno' from platform in folder: C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Using core 'arduino' from platform in folder: C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\sketch\\project_book2.ino.cpp" -o nul

Generating function prototypes...

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\sketch\\project_book2.ino.cpp" -o "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\sketch\\project_book2.ino.cpp" -o "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\sketch\\project_book2.ino.cpp.o"

Compiling libraries...

Compiling core...

Using precompiled core: C:\Users\NICKSA~1\AppData\Local\Temp\arduino_cache_348792\core\core_arduino_avr_uno_db01a873fb8fb140656c96a901f8467a.a

Linking everything together...

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.elf" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036\\sketch\\project_book2.ino.cpp.o" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/..\\arduino_cache_348792\\core\\core_arduino_avr_uno_db01a873fb8fb140656c96a901f8467a.a" "-LC:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036" -lm

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.elf" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.eep"

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.elf" "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.hex"

"C:\\Users\\Nick Savage\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\NICKSA~1\\AppData\\Local\\Temp\\arduino_build_354036/project_book2.ino.elf"

Sketch uses 4030 bytes (12%) of program storage space. Maximum is 32256 bytes.

Global variables use 230 bytes (11%) of dynamic memory, leaving 1818 bytes for local variables. Maximum is 2048 bytes.

C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:C:\Users\NICKSA~1\AppData\Local\Temp\arduino_build_354036/project_book2.ino.hex:i 



avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch



         System wide configuration file is "C:\Users\Nick Savage\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : COM5

         Using Programmer              : arduino

         Overriding Baud Rate          : 115200

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

An error occurred while uploading the sketch


Hi @savagen. Please add a reply here on this forum topic to tell us which Arduino board you are using.

I see from the output you shared that you have Arduino IDE configured for use with an UNO R3 board. However, something that can be confusing is there are multiple boards with "UNO" in their name:

We need to be certain of exactly which one you have. The reason is that the problem might be caused by the IDE not being correctly configured for your specific board.

If you aren't sure which one you have, you can provide a picture of the board or a link to the place you bought it from and we'll see if we can identify it.

Board is mega2560 R3.

Which board have you got selected in the IDE ?

its elegoo mega 2560. can't see how I put that in board choices?

Try using "Arduino Mega or Mega 2560"

thanks!!! that works. much appreciated!

Glad it worked

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