四博智联产品售后

 找回密码
 立即注册
搜索
查看: 11249|回复: 0

键控Led灯

[复制链接]

252

主题

302

帖子

1817

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1817
发表于 2015-12-25 17:05:41 | 显示全部楼层 |阅读模式
  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. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|四博智联 Inc. ( 粤ICP备15034758号-1

GMT+8, 2024-3-29 18:34 , Processed in 0.081542 second(s), 35 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表