Difference between revisions of "Light Indicator (X02)"
(→Tweaking) |
(→Assembly) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[File: | + | [[File:Light_Indicator_X02_Front_View.jpg|right|thumb|Light Indicator Project Build]] |
=About= | =About= | ||
This project uses the '''[[Sensor-Light-A1|Light Sensor]]''' to change the colors of a '''[[Sensor-Color_LED|ColorLED]]''' or '''[[mCookie-LED_Matrix|LED Matrix]]'''. Depending the amount of light the light sensor detects the color on the ColorLED or LED Matrix will change accordingly. | This project uses the '''[[Sensor-Light-A1|Light Sensor]]''' to change the colors of a '''[[Sensor-Color_LED|ColorLED]]''' or '''[[mCookie-LED_Matrix|LED Matrix]]'''. Depending the amount of light the light sensor detects the color on the ColorLED or LED Matrix will change accordingly. | ||
Line 31: | Line 31: | ||
##'''(Bottom of Stack)''' Sensor Hub '''(Top of Stack)''' | ##'''(Bottom of Stack)''' Sensor Hub '''(Top of Stack)''' | ||
##'''(Bottom of Stack)''' Core | LED Matrix (102 / 202 / 302 Kit compatible build). '''(Top of Stack)''' | ##'''(Bottom of Stack)''' Core | LED Matrix (102 / 202 / 302 Kit compatible build). '''(Top of Stack)''' | ||
− | #Stack the two stacks onto the mBattery | + | #Stack the two stacks onto the mBattery or all on top of USBTTL. |
#Plug in the MicroUSB cable to the mBattery to a computer. | #Plug in the MicroUSB cable to the mBattery to a computer. | ||
Line 52: | Line 52: | ||
=Tweaking= | =Tweaking= | ||
− | + | ==userDef.h== | |
'''DEBUG''' will enable debugging mode. Which outputs information to the Serial Port. | '''DEBUG''' will enable debugging mode. Which outputs information to the Serial Port. | ||
+ | |||
+ | '''LED_MATRIX_PIN''' pin that the LED Matrix is connected to. | ||
+ | |||
+ | '''NUMPIXELS''' defines the number of pixels on the LED Matrix. | ||
+ | |||
+ | '''LIGHT_PIN''' pin that the light sensor is connected to. | ||
'''LIGHT_VALUE1''' is the first break point light sensor value. Values below this will output green on the Color LED. Values below this will output blue on the Color LED. | '''LIGHT_VALUE1''' is the first break point light sensor value. Values below this will output green on the Color LED. Values below this will output blue on the Color LED. | ||
Line 77: | Line 83: | ||
=Usage= | =Usage= | ||
− | Turn on the project and | + | Turn on the project and provide different amounts of light to the light sensor. The LED Matrix or Color LED will change colors based on the amount of light being sensed between green, blue and red. |
Latest revision as of 21:52, 1 May 2017
Contents
About
This project uses the Light Sensor to change the colors of a ColorLED or LED Matrix. Depending the amount of light the light sensor detects the color on the ColorLED or LED Matrix will change accordingly.
This project was designed for the second generation mCookie Maker kits (102 Basic, 202 Advanced, and 302 Expert kits).
Required Materials
This project can be built in two ways. Either using the LED Matrix (102 Basic Kit, 202 Advanced Kit or 302 Expert Kit required) or ColorLED (302 Expert Kit required) as the LED output.
102 Basic Kit, 202 Advanced Kit, or 302 Expert Kit required
- 1 x mCookie Core
- 1 x mCookie USB TTL (102 Kit) or 1 x mBattery (202/302 Kit)
- 1 x mCookie Sensor Hub
- 1 x LED Matrix
- 1 x Light Sensor
- 1 x MicroUSB Cable
302 Expert Kit required
- 1 x mCookie Core
- 1 x mBattery (202/302 Kit)
- 1 x mCookie Sensor Hub
- 1 x ColorLED
- 1 x Light Sensor
- 1 x MicroUSB Cable
Build
Assembly
NOTE: When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.
- Connect a Light Sensor to the Sensor Hub on Pin A2/A3.
- Connect a ColorLED to the Sensor Hub on Pin A0/A1 (302 Expert Kit compatible build).
- Create two stacks containing:
- (Bottom of Stack) Sensor Hub (Top of Stack)
- (Bottom of Stack) Core | LED Matrix (102 / 202 / 302 Kit compatible build). (Top of Stack)
- Stack the two stacks onto the mBattery or all on top of USBTTL.
- Plug in the MicroUSB cable to the mBattery to a computer.
Program
1. Connect mCookie Core to the PC with the USB Cable. Open the Microduino IDE.
2. Download the project file and unzip: File:Light Indicator X02.zip.
- Using the Microduino IDE and go to File > Open... and navigate to the unzipped folder. Open the Light_Indicator_X02.ino file.
3. Select the board, processor and port:
- Go to Tools > Board and select Microduino/mCookie-Core (328p)
- Go to Tools > Processor and select Atmega328P16M,5V
- Go to Tools > Port and select the available port
4. Upload the program by clicking on the right arrow icon on the top left of the window. Or under Sketch > Upload.
NOTE: If not using the default Core module included in the kits, please follow the selecting the board and processor guide.
Debugging
- Open the Serial monitor. Information on the light sensor value is displayed. This can be used to change values on the light value break points under #Tweaking
Tweaking
userDef.h
DEBUG will enable debugging mode. Which outputs information to the Serial Port.
LED_MATRIX_PIN pin that the LED Matrix is connected to.
NUMPIXELS defines the number of pixels on the LED Matrix.
LIGHT_PIN pin that the light sensor is connected to.
LIGHT_VALUE1 is the first break point light sensor value. Values below this will output green on the Color LED. Values below this will output blue on the Color LED.
- Range is 0~1023
- Default is 400
- Should be set to less than LIGHT_VALUE2
LIGHT_VALUE2 is the first break point light sensor value. Values below this will output blue on the Color LED. Values above this will output red on the Color LED.
- Range is 0~1023
- Default is 800
- Should be set to greater than LIGHT_VALUE1
LED COLOR: |-----GREEN-----|------BLUE------|------RED------|
LIGHT VALUE: 0 LIGHT_VALUE1 LIGHT_VALUE2 1023
- NOTE: Light sensor values can be seen in debug mode as an output to the serial monitor.
MAXIMUM_BRIGHTNESS is the maximum brightness value the LED Matrix / ColorLED can output.
- Range is 0 to 255
- Default is 20
- CAUTION: Be careful on high values as the LEDs can be extremely bright!
Usage
Turn on the project and provide different amounts of light to the light sensor. The LED Matrix or Color LED will change colors based on the amount of light being sensed between green, blue and red.