Difference between revisions of "Nightlight Project (X02)"

From Microduino Wiki
Jump to: navigation, search
(Tweaking)
(Program)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Nightight Project.jpg|right|thumb|Nightlight Project Build]]
+
[[File:Nightlight_X02.png|right|thumb|Nightlight Project Build]]
 
=About=
 
=About=
 
This project uses the [[Sensor-Light-A1|Light Sensor]] to detect ambient light and turns on or off the LED Matrix depending how dark it is in the room.
 
This project uses the [[Sensor-Light-A1|Light Sensor]] to detect ambient light and turns on or off the LED Matrix depending how dark it is in the room.
Line 27: Line 27:
 
1. Connect [[mCookie-Core|mCookie Core]] to the PC with the USB Cable. Open the Microduino IDE.
 
1. Connect [[mCookie-Core|mCookie Core]] to the PC with the USB Cable. Open the Microduino IDE.
  
2. Copy and paste the code below and upload.
+
2. Download the project file and unzip: '''<big>[[File:Nightlight_X02.zip]]</big>'''.
 +
*Using the Microduino IDE and go to '''File > Open...''' and navigate to the unzipped folder. Open the '''Nightlight_X02.ino''' file.  
  
<source lang="cpp">
 
 
</source>
 
 
3. Select the board, processor and port:
 
3. Select the board, processor and port:
 
*Go to '''Tools > Board'''  and select '''Microduino/mCookie-Core (328p)'''
 
*Go to '''Tools > Board'''  and select '''Microduino/mCookie-Core (328p)'''
Line 37: Line 35:
 
*Go to '''Tools > Port''' and select the available port
 
*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'''.
 
4. Upload the program by clicking on the '''right arrow icon''' on the top left of the window. Or under '''Sketch > Upload'''.
==Debugging==
+
 
*Open the Serial monitor. Information will print out when the first clap is detected as "First clap detected!".  
+
'''NOTE''': If not using the default Core module included in the kits, please follow the '''[[Selecting_board,_processor,_and_port|selecting the board and processor guide]]'''.
*Then a value will print out which is the silent value. If it is under the threshold, "Silence detected!" will print.  
+
 
*"Second clap detected!" will print if it detected a second clap.
+
=Debugging=
==Tweaking==
+
*Open the Serial monitor. Information will print out when the Touch Button has been activated. Also the Current Max brightness value will be printed out.
 +
 
 +
=Tweaking=
 
Variables can be edited to change the threshold / detection value for various functions to better fine tune to your environment.  
 
Variables can be edited to change the threshold / detection value for various functions to better fine tune to your environment.  
 +
 +
'''DEBUG''' uncomment to debug
 +
 +
'''PIN''' is the digital IO pin connected to the NeoPixels (LED Matrix)
 +
 +
'''LED_NUM''' is the number of NeoPixels in the LED Matrix
 +
 +
'''LIGHT_SENSOR'''  is the pin the Light Sensor is connected to.
 +
 +
'''TOUCH_SENSOR'''  is the pin the Touch Sensor is connected to.
  
 
'''MAX_BRIGHTNESS''' will change the maximum brightness value. Range between 0 (off) and 255 (blindingly bright). Please be cautious with values above 40.
 
'''MAX_BRIGHTNESS''' will change the maximum brightness value. Range between 0 (off) and 255 (blindingly bright). Please be cautious with values above 40.
Line 55: Line 65:
 
*Default is 0 (off)
 
*Default is 0 (off)
  
'''PRESS_DELAY'' will change how long between button presses before register another button press to switch between brightness levels. In milliseconds.
+
'''PRESS_DELAY''' will change how long between button presses before register another button press to switch between brightness levels. In milliseconds.
 
*Default is 1000 -- 1 second
 
*Default is 1000 -- 1 second
  
 
=Usage=
 
=Usage=
Clap once, wait about 1 second, then clap another time. The LED should turn on and a beep noise will occur. Repeating the sequence will turn off the LED.
+
Based on the light level the Light sensor detects. The LED Matrix will turn on accordingly. The darker the room (or if you cover the sensor), the brighter the LED Matrix will shine. 3 brightness levels can be toggled with the touch button with an off mode after maximum brightness mode. Brightness modes will loop around.

Latest revision as of 15:33, 8 May 2017

Nightlight Project Build

About

This project uses the Light Sensor to detect ambient light and turns on or off the LED Matrix depending how dark it is in the room.

This project was designed for the second generation mCookie Maker kits (102 Basic, 202 Advanced and 302 Expert kits).

Required Materials

  • 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 Touch Button
  • 2 x Sensor Cable
  • 1 x MicroUSB Cable

Build

NOTE: When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.

  1. Connect the Light Sensor to the Sensor Hub on Pin A2/A3
  2. Connect the Touch Button to the Sensor Hub on Pin 2/3
  3. Grab the mCookie USBTTL or mBattery and Stack the mCookie Core on top.
  4. Stack the mCookie LED Matrix on top of that.
  5. Stack the mCookie Sensor on top of that.
  6. Plug in the MicroUSB cable to the mCookie USBTTL or 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:Nightlight X02.zip.

  • Using the Microduino IDE and go to File > Open... and navigate to the unzipped folder. Open the Nightlight_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 will print out when the Touch Button has been activated. Also the Current Max brightness value will be printed out.

Tweaking

Variables can be edited to change the threshold / detection value for various functions to better fine tune to your environment.

DEBUG uncomment to debug

PIN is the digital IO pin connected to the NeoPixels (LED Matrix)

LED_NUM is the number of NeoPixels in the LED Matrix

LIGHT_SENSOR is the pin the Light Sensor is connected to.

TOUCH_SENSOR is the pin the Touch Sensor is connected to.

MAX_BRIGHTNESS will change the maximum brightness value. Range between 0 (off) and 255 (blindingly bright). Please be cautious with values above 40.

  • Adjustable between 0 ~255
  • Default is 40

BRIGHTNESS_SCALAR will change the value that the brightness increases by each press of the touch sensor.

  • Default is 10

DEFAULT_BRIGHTNESS will change the default brightness should be less than the Max Brightness. This is how bright the LED Matrix will be at an minimum regardless of the input.

  • Adjustable between 0~255 -- should be less than MAX_BRIGHTNESS
  • Default is 0 (off)

PRESS_DELAY will change how long between button presses before register another button press to switch between brightness levels. In milliseconds.

  • Default is 1000 -- 1 second

Usage

Based on the light level the Light sensor detects. The LED Matrix will turn on accordingly. The darker the room (or if you cover the sensor), the brighter the LED Matrix will shine. 3 brightness levels can be toggled with the touch button with an off mode after maximum brightness mode. Brightness modes will loop around.