Hello,
i want to build little gokart controlled by an Arduino Mega.
I want to control the gas with a servo and the servo with a potentiometer.
Additionally i want to add a button to the brake if that button gets pressed the servo should go back to 0.
It is working perfectly fine if i leave that button part out, but when i add it nothing is working.
Can anyone help me with that problem?
Here is my code
#include <Servo.h>
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 1;
Servo meinServo;
What servo position do you want when the button is pressed?
You're not using the "if" syntax correctly. You're ending your if statements with a semicolon and forcing the conditional event to occur each loop.
Please read "How to use this forum" item #7 and use code tags.
Use "autoformat" under tools to format your code.
This is a really easy problem to solve. My bet is you just need to add an "else" in front a couple "if"s. But the if statements need to be written correctly for it to work.