C:\Users_\Documents\Arduino\sketch_aug20c\New_tab_1.ino: In function 'void setup()':
New_tab_1:4:6: error: redefinition of 'void setup()'
void setup(){
^~~~~
C:\Users_\Documents\Arduino\sketch_aug20c\sketch_aug20c.ino:8:6: note: 'void setup()' previously defined here
void setup()
^~~~~
C:\Users_\Documents\Arduino\sketch_aug20c\New_tab_1.ino: In function 'void loop()':
New_tab_1:9:6: error: redefinition of 'void loop()'
void loop(){
^~~~
C:\Users_\Documents\Arduino\sketch_aug20c\sketch_aug20c.ino:18:6: note: 'void loop()' previously defined here
void loop()
^~~~
exit status 1
redefinition of 'void setup()'
I dont understand what the problem is with this.
Here is my code:
#include<Servo.h>
Servo servo;
int x_axis;
int servo_val;
void setup()
{
pinMode(A0,INPUT);
servo.attach(10);
}
void loop()
{
x_axis=analogRead(A0);
servo_val=map(x_axis,0,1023,0,180);
servo.write(servo_val);
}
You apparently have two .ino files in you sketch. When they are compiled they copied into a single file which results in duplicate definitions - just like the error messages tell you.
As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming Questions category of the forum
You have 2 tabs in the IDE, each with a setup() and loop() function. The code in both tabs will be compiled together by the IDE and you cannot have more than one function with the same name in the combined sketch (not quite true but applicable here)