Difference between revisions of "Grumpy Grandpa (X02)"

From Microduino Wiki
Jump to: navigation, search
(Usage)
(userDef.h)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Grumpy Grandpa Project.jpg|right|thumb|Grumpy Grandpa Project Build]]
+
[[File:Grumpy_Grandpa_X02.jpg|right|thumb|Grumpy Grandpa Project Build]]
 
=About=
 
=About=
This project uses the [[Microphone]] to detect noise levels. If the noise levels are too loud for a period of time. Grandpa will be angry and start yelling (buzzer sounds).
+
This project uses the [[Sensor-MIC|Microphone]] to detect noise levels. If the noise levels are too loud for a period of time. Grandpa will be angry and start yelling (buzzer sounds).
  
 
This project was designed for the second generation mCookie Maker kits (102 Basic, 202 Advanced and 302 Expert kits).
 
This project was designed for the second generation mCookie Maker kits (102 Basic, 202 Advanced and 302 Expert kits).
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:Grumpy_Grandpa_X02.zip]]</big>'''.
 +
*Using the Microduino IDE and go to '''File > Open...''' and navigate to the unzipped folder. Open the '''Grumpy_Grandpa_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 on the Microphone value is printed out. This can used to modify the code to change the '''MIC_MIN''' value.
 +
*At the moment Grandpa becomes grumpy. "I AM GRUMPY!" is printed.
 +
 
 +
=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.  
 +
==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.
+
'''MIC_PIN''' is the pin that the MIC is connected to.
 +
 
 +
'''BUZZER_PIN''' is the pin that the Buzzer is connected to.
 +
 
 +
'''KEY_PIN''' is the pin that the Button is connected to.
  
 
'''MIC_MIN''' is the minimum value from the Microphone that will anger Grandpa.
 
'''MIC_MIN''' is the minimum value from the Microphone that will anger Grandpa.
Line 52: Line 59:
 
'''NOISE_TIME''' is the time in milliseconds (1 second = 1000 milliseconds) where minimum noise level is maintained which will anger Grandpa.  
 
'''NOISE_TIME''' is the time in milliseconds (1 second = 1000 milliseconds) where minimum noise level is maintained which will anger Grandpa.  
 
*Default is 200
 
*Default is 200
 +
 
=Usage=
 
=Usage=
 
Cause enough noise ('''MIC_MIN''') for a time period ('''NOISE_TIME''') and this will anger Grandpa. Grandpa will start yelling (making noise with the Buzzer). Once, Grandpa is angry. Calm him down by pressing the button.
 
Cause enough noise ('''MIC_MIN''') for a time period ('''NOISE_TIME''') and this will anger Grandpa. Grandpa will start yelling (making noise with the Buzzer). Once, Grandpa is angry. Calm him down by pressing the button.

Latest revision as of 22:13, 3 May 2017

Grumpy Grandpa Project Build

About

This project uses the Microphone to detect noise levels. If the noise levels are too loud for a period of time. Grandpa will be angry and start yelling (buzzer sounds).

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 Crash Sensor
  • 1 x Microphone Sensor
  • 1 x Buzzer
  • 3 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 Crash Sensor to the Sensor Hub on Pin 4/5
  2. Connect the Buzzer to the Sensor Hub on Pin 6/7
  3. Connect the Microphone to the Sensor Hub on Pin A0/A1
  4. Grab the mCookie USBTTL or mBattery and Stack the mCookie Core on top.
  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:Grumpy Grandpa X02.zip.

  • Using the Microduino IDE and go to File > Open... and navigate to the unzipped folder. Open the Grumpy_Grandpa_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 Microphone value is printed out. This can used to modify the code to change the MIC_MIN value.
  • At the moment Grandpa becomes grumpy. "I AM GRUMPY!" is printed.

Tweaking

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

userDef.h

DEBUG will enable debugging mode. Which outputs information to the Serial Port.

MIC_PIN is the pin that the MIC is connected to.

BUZZER_PIN is the pin that the Buzzer is connected to.

KEY_PIN is the pin that the Button is connected to.

MIC_MIN is the minimum value from the Microphone that will anger Grandpa.

  • Adjustable between 0 ~ 1023
  • Default is 200

NOISE_TIME is the time in milliseconds (1 second = 1000 milliseconds) where minimum noise level is maintained which will anger Grandpa.

  • Default is 200

Usage

Cause enough noise (MIC_MIN) for a time period (NOISE_TIME) and this will anger Grandpa. Grandpa will start yelling (making noise with the Buzzer). Once, Grandpa is angry. Calm him down by pressing the button.