Servo servoLeft; // Define left servo
Servo servoRight; // Define right servo
const int buttonPin = 2; // the number of the pushbutton pin
void setup() {
servoLeft.attach(A5); // Set left servo to analog pin 5
servoRight.attach(A4);// Set right servo to analog pin 4
pinMode(buttonPin, INPUT);
}
void loop()
if (buttonState == HIGH) {
void forward() {
servoLeft.write(0);
servoRight.write(180);
else(
}
oqibidipo:
Actually GCC does support nested functions, but only in C, not C++.
Actually, I wrote "C/C++ (or at least the Arduino dialect) doesn't allow nested function definitions".
I know very well that nested functions can be allowed.
Arduino: 1.6.12 (Mac OS X), Board: "Arduino/Genuino Uno"
/Users/svteacher/Documents/Arduino/sketch_nov13a/sketch_nov13a.ino: In function 'void loop()':
sketch_nov13a:22: error: no match for call to '(Servo) (int)'
servoLeft(180);
^
sketch_nov13a:23: error: no match for call to '(Servo) (int)'
servoRight(0);
^
sketch_nov13a:25: error: no match for call to '(Servo) (int)'
servoLeft(90);
^
sketch_nov13a:26: error: no match for call to '(Servo) (int)'
servoRight(90);
^
exit status 1
no match for call to '(Servo) (int)'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
im getting this after i type this
[void loop(){
val==digitalRead(buttonPin); //read input value
if (val=HIGH) { //check if input is high
servoLeft(180);
servoRight(0);
delay(6000);
servoLeft(90);
servoRight(90);
}]