Spaceship Interface Problem

Can someone please explain to me why it is giving me an error. It says, "Problem uploading to the board."

int switchState = 0;

void setup(){
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(2,INPUT);
// put your setup code here, to run once:
}

void loop(){
switchState = digitalRead(2);
// put your main code here, to run repeatedly:
if (switchState == LOW) {

digitalWrite(3, HIGH); // green LED
digitalWrite(4, LOW); // red LED
digitalWrite(5, LOW); // red LED

}

else {
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(250);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250);

}
}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please do this:

  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the process fails you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

Does that make it more efficient. I had to use the code tags twice because it would not let me highlight the whole code.

int switchState = 0;

void setup(){
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(2,INPUT);
  // put your setup code here, to run once:
}

void loop(){
  switchState = digitalRead(2);
  // put your main code here, to run repeatedly:
  if (switchState == LOW) {
    
    digitalWrite(3, HIGH); // green LED
    digitalWrite(4, LOW); // red LED
    digitalWrite(5, LOW); // red LED
  
  }
  else {
    digitalWrite(3, LOW); 
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);

    delay(250);
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    delay(250);
  
  }
 }

nickorion562:
It says, “Problem uploading to the board.”

That’s not an issue with your code. That is an issue with the upload itself.

Is that really all it said? Usually it doesn’t paraphrase. Why don’t you copy and paste the actual output here. Don’t you think that might be more useful?

Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Uno"

Archiving built core (caching) in: /var/folders/mr/5wnps1wn4v53tqsg5rc8hqsh0000gn/T/arduino_cache_970737/core/core_arduino_avr_uno_473724b1739d28fe8233cc72278659e2.a
Sketch uses 1220 bytes (3%) of program storage space. Maximum is 32256 bytes.
Global variables use 11 bytes (0%) of dynamic memory, leaving 2037 bytes for local variables. Maximum is 2048 bytes.
/private/var/folders/mr/5wnps1wn4v53tqsg5rc8hqsh0000gn/T/AppTranslocation/CF7FE77F-AFD7-4ED9-936B-F3F6266F0517/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/private/var/folders/mr/5wnps1wn4v53tqsg5rc8hqsh0000gn/T/AppTranslocation/CF7FE77F-AFD7-4ED9-936B-F3F6266F0517/d/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM1 -b115200 -D -Uflash:w:/var/folders/mr/5wnps1wn4v53tqsg5rc8hqsh0000gn/T/arduino_build_752084/sketch_nov09a.ino.hex:i 

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/private/var/folders/mr/5wnps1wn4v53tqsg5rc8hqsh0000gn/T/AppTranslocation/CF7FE77F-AFD7-4ED9-936B-F3F6266F0517/d/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/nicklausorionhanson/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : COM1
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "COM1": No such file or directory

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

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

To: Delta_G
Yes, that is all it said after I hit upload.

nickorion562:
I had to use the code tags twice because it would not let me highlight the whole code.

If you click the code tag button first then paste the code it will work well for you.

nickorion562:

avrdude: ser_open(): can't open device "COM1": No such file or directory

You need to select the COM port of your Arduino from the Tools > Port menu.

nickorion562:
Yes, that is all it said after I hit upload.

No, that one line was not all it said. Why would you post that long string of what actually came out and then try to tell me that the one little line you mentioned earlier was all it said? You literally just contradicted yourself right there.

avrdude: ser_open(): can't open device "COM1": No such file or directory

See, it did say something important. Now we know that you are using COM1 which is almost never going to be your Arduino board. Which leads me (and apparently pert too) to believe you've got the wrong port selected.

I believe that that helped pert because it says, "Done uploading". "avrdude done. Thank you". But my LED's are still not lighting up.

I understand Delta-G. Do you know why my LED lights aren't activating?

First step is to use a simplified test sketch to verify that the LEDs are working. Here's one that's based on File > Examples > 01.Basics > Blink but it makes it easy to use with any pin, rather than only the built in LED:

byte LEDpin = 3;

void setup() {
  pinMode(LEDpin, OUTPUT);
}

void loop() {
  digitalWrite(LEDpin, HIGH);
  delay(1000);
  digitalWrite(LEDpin, LOW);
  delay(1000);
}

Upload that sketch to your board and verify that your green LED connected to pin 3 is blinking.
Next change the line:

byte LEDpin = 3;

to each of the other pins your LEDs are connected to, upload, and verify they are working.

I put in the code that you gave me and went through the menu procisely and the green light did not turn on.

Then you have a problem with your wiring. You need to show us clearly how you have the LEDs connected to your Arduino. You can find a guide for how to attach and embed images here:

Here is an image or images.

Here is one of my images.

Can you see the image or images.

I am trying to upload this image sorry if it is not uploading.

I got it. It was wiring malfunction. Thank you very much for the support!