error compiling for board

this has been solved thanks to the lovely folks in the comments btw
for you guys who struggle and is too lazy to read heres the summary
DONT SAVE BACKUPS INSIDE THE SAME FOLDER
thats it
here is the original post
|
V

ive been having problems with my code
im super new to arduino ( 3 days experience) and i made a code that is supposed to allow for adjustable rgb led ( so that i can adjust the R the G and the B by using values from 3 seperate variable resistors. is that confusing? it probably is.) here is my code

int R=11;
int G=10;
int B=9;
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
void setup() {
Serial.begin(9600);
pinMode(R,OUTPUT);
pinMode(G,OUTPUT);
pinMode(B,OUTPUT);
// put your setup code here, to run once:

}

void loop() {
a=analogRead(A0);
b=analogRead(A1);
c=analogRead(A2);
Serial.println(a);
d=map(a,0,1023,0,255);
e=map(b,0,1023,0,255);
f=map(c,0,1023,0,255);
analogWrite(R,d );
analogWrite(G,e );
analogWrite(B,f );
}

its garbage i know.
i made this code like maybe 8 hours before this post( in the morning ) and now that ive started working on it again i wanted to try adding some stuff to it ( if else functions where if the value of d e or f is more than 200 it would blink with a delay of .05 seconds ) and now it gets this error message btw just ignore my poor file name choice

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:1:5: error: redefinition of 'int R'

int R=11;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:1:5: note: 'int R' previously defined here

int R=11;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:2:5: error: redefinition of 'int G'

int G=10;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:2:5: note: 'int G' previously defined here

int G=10;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:3:5: error: redefinition of 'int B'

int B=9;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:3:5: note: 'int B' previously defined here

int B=9;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:4:5: error: redefinition of 'int a'

int a=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:4:5: note: 'int a' previously defined here

int a=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:5:5: error: redefinition of 'int b'

int b=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:5:5: note: 'int b' previously defined here

int b=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:6:5: error: redefinition of 'int c'

int c=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:6:5: note: 'int c' previously defined here

int c=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:7:5: error: redefinition of 'int d'

int d=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:7:5: note: 'int d' previously defined here

int d=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:8:5: error: redefinition of 'int e'

int e=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:8:5: note: 'int e' previously defined here

int e=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:9:5: error: redefinition of 'int f'

int f=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:9:5: note: 'int f' previously defined here

int f=0;

^

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino: In function 'void setup()':

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:10:6: error: redefinition of 'void setup()'

void setup() {

^~~~~

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:10:6: note: 'void setup()' previously defined here

void setup() {

^~~~~

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino: In function 'void loop()':

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\adjustable RGB light ( it works )(needs 3 turny things).ino:19:6: error: redefinition of 'void loop()'

void loop() {

^~~~

C:\Users\hp\Desktop\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_\arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that_.ino:19:6: note: 'void loop()' previously defined here

void loop() {

^~~~

exit status 1
Error compiling for board Arduino/Genuino Uno.

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

i then tried to revert the code back to its original state which i am sure it is the original one because i took a picture of it and it still gets the same error message

im pretty sure its just going to boil down to me being a retard and forgetting a ; or a , but i still need your help.

thankyou in advance.

I compiled your code for an Uno, and got this

Sketch uses 2578 bytes (7%) of program storage space. Maximum is 32256 bytes.
Global variables use 200 bytes (9%) of dynamic memory, leaving 1848 bytes for local variables. Maximum is 2048 bytes.

(Your sketch is too long BTW)

It looks like you have multiple .ino files in your sketch that contain the same code, thus the “redefinition of” errors. Your sketch folder looks like this:

C:\Users\hp\Desktop
|arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that
|arduino_adjustable_RGB_led_that_uses_3_variable_resistors_that.ino
|_adjustable RGB light ( it works )(needs 3 turny things).ino

I suspect one of those files was intended to be a backup of your sketch. Sketches can contain multiple .ino files. Each .ino file will be shown as a tab in the Arduino IDE. When the sketch is compiled, all the code in all the tabs is compiled. If you want to make backup copies of the sketch, you need to save them somewhere outside of the sketch folder.