Arduino-光控灯

网友投稿 2020-01-01 10:55

1、实验材料

(1)UNO  R3板(2)面包板(3)5根连接线(4)1个Led灯(5)1个10K电阻(6)1个1K电阻(7)1个光敏电阻

2、原理图

https://cdn.china-scratch.com/timg/200103/1055295I8-0.jpg

3、连接图

https://cdn.china-scratch.com/timg/200103/1055292154-1.jpg

4、Mixly编程

https://cdn.china-scratch.com/timg/200103/10553060T-2.jpg

5、Arduino IDE编程

int sensorValue = 0; int ledPin = 10;void setup() {pinMode(ledPin, OUTPUT);Serial.begin(9600);}void loop() {sensorValue = analogRead(A0);Serial.println(sensorValue);if (sensorValue > 400) {digitalWrite(ledPin, HIGH);} else {digitalWrite(ledPin, LOW);}delay(100);}

声明:本文章由网友投稿作为教育分享用途,如有侵权原作者可通过邮件及时和我们联系删除:freemanzk@qq.com