PROBLEM!! Knight Rider sketch uploading=Not Compling!

After I copy and pasted the Knight Rider code to the code section of my Arduino Nano V3.0 with ATmega328 chip. I click to upload and a red bar comes on below and says not compling?

It is easier to help with code that generates errors if we are provided with the code and the complete text of the errors (in code tags).

Can you post the code or link to where you got the code? Was the code specifically for the Nano?

It shouldn't be too hard to write the code yourself by modifying the Blink LED example... I assume you can compile & run the Blink example?

...A lot of times it's easier to write your own program that you fully-understand then to debug someone else's program. And if you are beginning programmer, sequencing LEDs is fairly straightforward and it's a good-simple beginner project.

/* Knight Rider 1


  • Basically an extension of Blink_LED.
  • (cleft) 2005 K3, Malmo University
  • @author: David Cuartielles
  • @hardware: David Cuartielles, Aaron Hallborg
    */

int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int timer = 100;

void setup(){
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
}

void loop() {
digitalWrite(pin2, HIGH);
delay(timer);
digitalWrite(pin2, LOW);
delay(timer);

digitalWrite(pin3, HIGH);
delay(timer);
digitalWrite(pin3, LOW);
delay(timer);

digitalWrite(pin4, HIGH);
delay(timer);
digitalWrite(pin4, LOW);
delay(timer);

digitalWrite(pin5, HIGH);
delay(timer);
digitalWrite(pin5, LOW);
delay(timer);

digitalWrite(pin6, HIGH);
delay(timer);
digitalWrite(pin6, LOW);
delay(timer);

digitalWrite(pin7, HIGH);
delay(timer);
digitalWrite(pin7, LOW);
delay(timer);

digitalWrite(pin6, HIGH);
delay(timer);
digitalWrite(pin6, LOW);
delay(timer);

digitalWrite(pin5, HIGH);
delay(timer);
digitalWrite(pin5, LOW);
delay(timer);

digitalWrite(pin4, HIGH);
delay(timer);
digitalWrite(pin4, LOW);
delay(timer);

digitalWrite(pin3, HIGH);
delay(timer);
digitalWrite(pin3, LOW);
delay(timer);
}

I have run the LED Blink example. I followed the same procedure to upload this code for knight ridArduino: 1.6.3 (Windows 8.1), Board: "Arduino Nano, ATmega328"

sketch_apr30a.ino: In function 'void setup()':

sketch_apr30a.ino:81:6: error: redefinition of 'void setup()'

sketch_apr30a.ino:21:6: error: 'void setup()' previously defined here

sketch_apr30a.ino: In function 'void loop()':

sketch_apr30a.ino:86:6: error: redefinition of 'void loop()'

sketch_apr30a.ino:30:6: error: 'void loop()' previously defined here

Error compiling.

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

I am definitely a beginner at programming. I have technical degree in Electrical Theory but we only delt with Industrial or Power stations no Elctronics only general purpose motor controls, relays, timers ( a few solid state) and I worked in the field for 15yrs and earned an Master Electrician license but I was crushed in an accident and am now disabled. So I understand the basics and can Identify electronic components and learn quickly. I appreciate the help. Learning from my mistakes will help a lot. Any Ideas????

TexasRoads:
After I copy and pasted the Knight Rider code to the code section of my Arduino Nano V3.0 with ATmega328 chip. I click to upload and a red bar comes on below and says not compling?

The problem sits in front of your monitor!

From your error messages "redefinition of 'void setup()'" and "redefinition of 'void loop()'" it looks like you pasted the same source twice into your editor window and tried compiling a doubled sketch code.

Here is the verbose output during compilation.

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Nano, ATmega328"

Build options changed, rebuilding all

C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\eightanaloginputs C:\Users\CAPURN~1\AppData\Local\Temp\build7771501482762976216.tmp\sketch_apr30a.cpp -o C:\Users\CAPURN~1\AppData\Local\Temp\build7771501482762976216.tmp\sketch_apr30a.cpp.o

sketch_apr30a.ino: In function 'void setup()':

sketch_apr30a.ino:81:6: error: redefinition of 'void setup()'

sketch_apr30a.ino:21:6: error: 'void setup()' previously defined here

sketch_apr30a.ino: In function 'void loop()':

sketch_apr30a.ino:86:6: error: redefinition of 'void loop()'

sketch_apr30a.ino:30:6: error: 'void loop()' previously defined here

Error compiling.

Damn,
You are right. I figured it was something simple. Thanks