四博智联产品售后

标题: 键控Led灯 [打印本页]

作者: ycf    时间: 2015-12-25 17:05
标题: 键控Led灯
  1. #define PIN_LED 16
  2. #define KEY_FLASH 0

  3. void setup() {
  4.   pinMode(PIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  5.   pinMode(KEY_FLASH, INPUT);
  6.   digitalWrite(PIN_LED,LOW);//点亮LED灯
  7. }

  8. // the loop function runs over and over again forever
  9. void loop() {
  10.   /*
  11.   digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
  12.                                     // but actually the LED is on; this is because
  13.                                     // it is acive low on the ESP-01)
  14.   delay(1000);                      // Wait for a second
  15.   digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
  16.   delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
  17.   */
  18.   if(digitalRead(KEY_FLASH)==0)
  19.   digitalWrite(PIN_LED,HIGH);
  20.   else
  21.   digitalWrite(PIN_LED,LOW);
  22.   
  23. }
复制代码







欢迎光临 四博智联产品售后 (http://bbs.doit.am/) Powered by Discuz! X3.2