“Light Indicator”的版本间的差异
(Created page with "{{Language|Light Indicator}} {| style="width: 800px;" |- | ==Objective== Here we make a simple light indicator, which classify light value in three levels—green, blue and re...") |
(→Objective) |
||
第4行: | 第4行: | ||
| | | | ||
==Objective== | ==Objective== | ||
− | Here we make a simple light indicator, which | + | Here we make a simple light indicator, which divides light value into three levels, that is, green, blue and red. |
==Principle== | ==Principle== |
2015年7月31日 (五) 08:25的最新版本
Language | English |
---|
ObjectiveHere we make a simple light indicator, which divides light value into three levels, that is, green, blue and red. PrincipleEquipment
Hardware Buildup
Software DebugginCode description: One part to acquire sensor values and the other part to control LED brightness and color change according the values.
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
#define Light_PIN A0
#define Light_value1 400
#define Light_value2 800
sensorValue = analogRead(Light_PIN);
if (sensorValue < Light_value1)
colorWipe(strip.Color(0, map(sensorValue, 10, 400, 0, 255), 0));
else if (sensorValue >= Light_value1 && sensorValue < Light_value2)
colorWipe(strip.Color(0, 0, map(sensorValue, 400, 800, 0, 255)));
else if (Light_value2 >= 800)
colorWipe(strip.Color(map(sensorValue, 800, 960, 0, 255), 0, 0));
ResultChange light intensity from weak to strong, you can see gree, blue and red in order. Video |