查看“Maple Lesson 10 - Light indicator"”的源代码
←
Maple Lesson 10 - Light indicator"
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Objective== In photoresistance experiment, the light is divided into two levels, strong or weak. This experiment will finish a light indictor using 4 LEDs and divides the light into 5 levels. Photoresistance receives the lighter, and light up more LED to achieve the purpose of instruction. ==Equipment== *[[ Microduino-CoreSTM32]] Microduino-CoreSTM32 is an ARM development board using STM32F103CBT6 chip. It use special Upin7 interface, the size is similar with a coin and fully compatible other Microduino modules. *Other hardware equipment **Breadboard Jumper one box **Breadboard one piece **Photoresistance one **LED Light-emitting diodes four **220Ω four **10k resistor one **USB Data cable one [[File:stm32-lesson11All.jpg|600px|center|thumb]] ==Schematic== [[File:stm32-lesson11-Principle.jpg|600px|center|thumb]] The photoresistance's connection in contrast to the last time, the purpose is let you know the usage of photoresistance deeply. photoresistance directly connects to the power supply at one end, the other end through a resistance to connect GND . The initial state is low and with the increase of light intensity voltage is higher and higher. ==Program== <source lang="cpp"> const int analogInPin = 14; const int ledPin = 4; float sensorValue = 0; // value read from the pot int xl=4000; //This is the basic environmental brightness variables, please check your own brightness values, fill out here is slightly greater than the measured value of the data but the data is less than the light void setup() { pinMode(analogInPin, INPUT); for(int i=3; i<=6;i++) //Set the I/O port 2 - 5 to output mode. { pinMode(i,OUTPUT); } } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); if (sensorValue>=1000) { digitalWrite(3,HIGH); digitalWrite(3,LOW); } if(sensorValue>1500) { digitalWrite(4,HIGH); digitalWrite(4,LOW); } if(sensorValue>2000) { digitalWrite(5,HIGH); digitalWrite(5,LOW); } if(sensorValue>2500) { digitalWrite(6,HIGH); digitalWrite(6,LOW); } SerialUSB.print("sensorValue = "); SerialUSB.println(sensorValue); delay(500); } </source> ==Result== When the light is very weak, lower the set minimum value, all the lights are off. With the increase of light, reach to a set level would light up an LED, to achieve the effect of instruction. Actually LED lamp has been flashing, because in order to make the light intensity is not a certain level, to put out the light of the level, directly after the lights out immediately, with no delay in the implementation process, as long as the grade, circulation processing, so it looks as if always on.[[File:stm32-lesson11Result.jpg|600px|center|thumb]] |}
返回至
Maple Lesson 10 - Light indicator"
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息