i have a pressure sensor hooked up to A0, a servo hooked up to pin 9, and two buttons, each should make the servo do what i tell it. the first button works but the second one doesn't?? i know someone can help.
#include <Servo.h>
int sensorPin = A0; // sensor connected to pin A0
int SensorValue = 0; // variable storing the sensor value
int buttonPin = 4; // "scramble boost"
int buttonState = 0;
int buttonStateII = 0;
int buttonPinII = 3; // overide open wastgate
Servo myservo;
void setup()
{
myservo.attach(9);
pinMode(buttonPinII, INPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin); // reads unlimited pressure button "scramble boost"..
buttonStateII = digitalRead(buttonPinII);
SensorValue = analogRead(sensorPin); // reads boost sensor pressure..
if (SensorValue < 800 || buttonState == HIGH) // wastegate stays closed if pressure is under preset or if scramble boost is activated.
{
myservo.writeMicroseconds(2000);
}
else if (SensorValue > 800 | buttonStateII == HIGH) // why doesnt this button work
{
myservo.writeMicroseconds(1000);
}
}