Difference between revisions of "Nightlight Project (X02)"

From Microduino Wiki
Jump to: navigation, search
(Created page with "right|thumb|Nightlight Project Build =About= This project uses the Light Sensor to detect ambient light and turns on or off...")
 
(Build)
Line 17: Line 17:
 
=Build=
 
=Build=
 
'''NOTE''': When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.
 
'''NOTE''': When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.
#Connect the Light Sensor to the Sensor Hub on Pin A0/A1
+
#Connect the Light Sensor to the Sensor Hub on Pin A2/A3
#Connect the Touch Button to the Sensor Hub on Pin A0/A1
+
#Connect the Touch Button to the Sensor Hub on Pin 2/3
 
#Grab the mCookie USBTTL or mBattery and Stack the mCookie Core on top.
 
#Grab the mCookie USBTTL or mBattery and Stack the mCookie Core on top.
 
#Stack the mCookie LED Matrix on top of that.
 
#Stack the mCookie LED Matrix on top of that.

Revision as of 00:03, 2 March 2017

File:Nightight Project.jpg
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. Copy and paste the code below and upload.

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.

Debugging

  • Open the Serial monitor. Information will print out when the first clap is detected as "First clap detected!".
  • 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.

Tweaking

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

CLAP_LOUDNESS_THRESHOLD will change the clapping loudness trigger point. Lower values means a weaker noise level is detected as a clap.

  • Adjustable between 0 ~ 1023
  • Default is 400

SILENT_LOUDNESS_THRESHOLD will change the silent registry level. Higher values will mean that higher noise levels will be registered as a silence.

  • Adjustable between 0 ~ 1023
  • Default is 200

PAUSE_TIME will change the time in which you are required to pause between claps in milliseconds. Lower values will detect faster claps, but there is settling time on the Microphone, which means too short of a pause time won't be detectable as silence.

  • Default is 200 milliseconds (1/5 of a second)

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.