2021年11月24日 星期三

magic fan

 boolean state = false;

boolean btn_up = true;

void setup()

{

  pinMode(7, INPUT);

  pinMode(8, OUTPUT);

  digitalWrite(8,LOW);

  pinMode(9, OUTPUT);

  digitalWrite(9,LOW);

  Serial.begin(9600);

}


void loop()

{

  if (digitalRead(7) == LOW && btn_up == HIGH)

  {Serial.println("test1");

    digitalWrite(8, state);

    state = !state;

    digitalWrite(9, state);

    btn_up = LOW;

  }

  else if (digitalRead(7) == HIGH && btn_up == LOW)

  {Serial.println("test2");

    btn_up = HIGH;

  }

  delay(100);

  }

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...