Light Indicator
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 |