MUstar

IoT 아두이노 0526 - no1

May 26th, 2017
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int pin_VI = 23;
  2. int pin_LED = 6;
  3. int pin_SW = 22;
  4. boolean i=0;
  5. boolean z=0;
  6. void setup() {
  7.   pinMode(pin_VI, OUTPUT);
  8.   pinMode(pin_LED, OUTPUT);
  9.   pinMode(pin_SW,INPUT_PULLUP);
  10.  
  11. }
  12.  
  13. void loop() {
  14.   if(digitalRead(pin_SW) == HIGH
  15.   ){
  16.     if(z==0){
  17.       z=1;
  18.       if(i==0){
  19.         digitalWrite(pin_LED,HIGH);
  20.         digitalWrite(pin_VI,HIGH);
  21.         //delay(500);
  22.         i=1;
  23.       }
  24.       else{
  25.         digitalWrite(pin_LED,LOW);
  26.         digitalWrite(pin_VI,LOW);
  27.         i=0;
  28.       }
  29.     }
  30.   }
  31.   else{z=0;}  
  32. }
RAW Paste Data