elseif(10 and 9 == HIGH)
{
analogWrite(A3,LOW);
analogWrite(A5,LOW);
analogWrite(A4,LOW);
}
}
else
{
analogWrite(A3,LOW);
}
}
}
}
'''
it keeps on giving me this error:
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino: In function 'void loop()':
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino:18:3: error: 'elseif' was not declared in this scope
elseif(10 and 9 == HIGH)
^~~~~~
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino:18:3: note: suggested alternative: 'sei'
elseif(10 and 9 == HIGH)
^~~~~~
sei
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino: At global scope:
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino:31:1: error: expected declaration before '}' token
}
^
exit status 1
Compilation error: 'elseif' was not declared in this scope
I'm a noob so if someone could please help me out here?
Note, I fixed your syntax. You still have miles to go. Your digital inputs are declared outputs, your analog pins don't need a mode, and your logic is flawed, as the else if will never execute - if 9 isn't high, you get there, but then you insist 9 must be high.
We could probably help you further, if you simply told us what you're trying to accomplish, then we can tell you what further is wrong.
I have some puppies here near my home there mom is still too attached for us to foster them so I am trying to make a board but people keep on running over it. That's why I am trying to get people to notice it by putting 2 photo diods, a few LEDs aligned in parallel(don't worry they work) and a buzzer(large). these are the pins and connections:
9 = photo1
10= photo2
A3 = LED1
A4 = buzzer
A5 = LED2
thank you so much for helping me out I am still learning and know it would still take me years to learn. I am transitioning to ESP32 and learning how to code it. Please do try to reply(if you have the time) thank you.
Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino: In function 'void setup()':
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino:1:6: error: redefinition of 'void setup()'
void setup()
^~~~~
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b.ino:1:6: note: 'void setup()' previously defined here
void setup()
^~~~~
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino: In function 'void loop()':
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b-mydog.ino:10:6: error: redefinition of 'void loop()'
void loop()
^~~~
C:\Users\hiarh\OneDrive\Documents\Arduino\sketch_feb20b\sketch_feb20b.ino:5:6: note: 'void loop()' previously defined here
void loop()
^~~~
exit status 1
Compilation error: redefinition of 'void setup()'
it's giving me this error.
Compilation error: redefinition of... usually means that whatever expression the compiler is indicating (e.g. 'void setup()' and 'void loop()' in this case) it has encountered earlier in the compile process. This usually means there is a duplicate instance of it.
You will notice that both pairs of error messages that you posted refer to a file called 'sketch_feb20b-mydog.ino' and then another called 'sketch_feb20b.ino'. Do you have both of these files present in the same sketch folder perhaps? If so, and they both have 'void setup()' and 'void loop()' in them, this might explain why you are getting that error. If one is an earlier version of the other, then it should be removed, or simply moved to another folder. On the other hand if the second file is an extension of the main sketch file (perhaps unlikely, but just in case) and contains additional functions, then void setup() and void loop() need to be removed from the second file. They should only appear once in the main file.