Light Indicator

来自Microduino Wikipedia
1304410487@qq.com讨论 | 贡献2015年7月31日 (五) 07:26的版本 (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...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索
Language English

Objective

Here we make a simple light indicator, which classify light value in three levels—green, blue and red.

Principle

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
SMicroduino-Sensorhub 1 Sensor pinboard
Microduino-Light 1 light-sensitive sensor
Microduino-Colorled 1 Colored led light
Microduino-BM 1 Battery management

Hardware Buildup

  • Setup 1:Connect CoreUSB to your PC, open program examples, select the right board (Microduino-CoreUSB) and download program through serial port.

light_led

  • Setup2:Connect the light-sensitive resistor to A0 pin of Sensorhub and the colored LED light to D6 pin.
Microduino-sensorhub rule.JPG
  • Setup5:Stack CoreUSB, Sensorhu and BM.
  • Setup6:Connect the battery to BM.

Software Debuggin

Code description: One part to acquire sensor values and the other part to control LED brightness and color change according the values.

  • Sensor pin description
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

#define Light_PIN A0
  • Light intensity pre-set value and the light can be divided into three levels.
#define Light_value1 400
#define Light_value2 800
  • Light detection
sensorValue = analogRead(Light_PIN);
  • The colored LED will adjust color and brightness according to light intensity.
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));

Result

Change light intensity from weak to strong, you can see gree, blue and red in order.

Video