Difference between revisions of "Light Indicator"
From Microduino Wiki
(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) |
||
Line 4: | Line 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== |
Revision as of 08:25, 31 July 2015
Language: | English • 中文 |
---|
ContentsObjectiveHere 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 |