int BOOS = 3;
int supervisor = 4;
int back_operator = 5;
int front_operator = 6;
int state_Boss = 0;
int state_supervisor = 0;
int state_back_operator = 0;
int state_front_operator = 0;
int LED = 8; //
void setup() {
pinMode(BOOS, INPUT_PULLUP);
pinMode(supervisor, INPUT_PULLUP);
pinMode(back_operator, INPUT_PULLUP);
pinMode(front_operator, INPUT_PULLUP);
//Serial.begin(9600);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}
void loop()
{
// read pushbuttons' states
state_Boss = digitalRead(BOOS);
state_supervisor = digitalRead(supervisor);
state_back_operator = digitalRead(back_operator);
state_front_operator = digitalRead(front_operator);
//Serial.print(state_Boss);
if ( (state_supervisor == HIGH && (state_back_operator == LOW || state_front_operator == LOW)) || state_Boss == LOW) //In pullup mode, the inital state of pushbutton was HIGH, so detect low voltage.
{
digitalWrite(LED, HIGH);
//state_Boss = 0;
}
else
{
digitalWrite(LED, LOW);
}
delay(50);
}
/* debounce
int keyGetNum(int key) {
if (digitalRead(key) == LOW) { // 检测按键按下
delay(20); // 消抖延时
while (digitalRead(key) == LOW); // 等待按键释放
delay(20); // 再次消抖
return 0; // 按键按下返回 0
}
return 1; // 按键未按下返回 1
}
*/