Difference between revisions of "Joystick Lantern (X02)"

From Microduino Wiki
Jump to: navigation, search
(Assembly)
(Tweaking)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Joystick Latern Project.jpg|right|thumb|Joystick Latern Project Build]]
+
[[File:Joystick Lantern X02.png|right|thumb|Joystick Lantern Project Build]]
 
=About=
 
=About=
This project uses the '''[[Joystick trinket (X02)|Joystick trinket]]''' to change the colors of a color '''[[ColorLED (X02)|ColorLED]]''' or '''[[mCookie-LED_Matrix|LED Matrix]]'''. Changing the direction of the Joystick will directly change the colors on the ColorLED or LED Matrix..
+
This project uses the '''[[Sensor-Joystick|Joystick trinket]]''' to change the colors of a color '''[[Sensor-Color_LED|ColorLED]]''' or '''[[mCookie-LED_Matrix|LED Matrix]]'''. Changing the direction of the Joystick will directly change the colors on the ColorLED or LED Matrix.
  
 
This project was designed for the second generation mCookie Maker kits (202 Advanced and 302 Expert kits).
 
This project was designed for the second generation mCookie Maker kits (202 Advanced and 302 Expert kits).
  
 
=Required Materials=
 
=Required Materials=
This project can be built in two ways. Either using the LED Matrix (202 Advanced Kit & 302 Expert Kit compatible) or ColorLED (302 Expert Kit compatible only) as the color changing latern.
+
This project can be built in two ways. Either using the LED Matrix (202 Advanced Kit or 302 Expert Kit required) or ColorLED (302 Expert Kit required) as the color changing lantern.
==202 Advanced Kit & 302 Expert Kit Compatible==
+
==202 Advanced Kit or 302 Expert Kit required==
 
*1 x mCookie Core
 
*1 x mCookie Core
 
*1 x mBattery (202/302 Kit)
 
*1 x mBattery (202/302 Kit)
Line 15: Line 15:
 
*1 x MicroUSB Cable
 
*1 x MicroUSB Cable
  
==302 Expert Kit Compatible ONLY==
+
==302 Expert Kit required==
 
*1 x mCookie Core
 
*1 x mCookie Core
 
*1 x mBattery (202/302 Kit)
 
*1 x mBattery (202/302 Kit)
Line 37: Line 37:
 
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:Joystick_Lantern_X02.zip]]</big>'''.
 +
*Using the Microduino IDE and go to '''File > Open...''' and navigate to the unzipped folder. Open the '''Joystick_Lantern_X02.ino''' file.  
  
<source lang="cpp">
+
3. Select the board, processor and port:
 
 
</source>
 
 
 
3. Find this code section and set the initial time of the RTC module.
 
<source lang="cpp">
 
setRtcTime(15, 5, 18, 1, 00, 00, 00);
 
</source>
 
The function signature is as follows: '''setRtcTime(year, month, day, week, hour, minute, sec);'''.
 
 
 
Replace the value of the time you wish to set. Once set, the module will maintain the time even when the power is off.
 
 
 
4. 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)'''
 
*Go to '''Tools > Processor''' and select '''Atmega328P16M,5V'''
 
*Go to '''Tools > Processor''' and select '''Atmega328P16M,5V'''
 
*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'''.
  
 
'''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]]'''.
 
'''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]]'''.
  
5. 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 on the color of the lantern will be displayed.
 +
 
 +
=Tweaking=
 +
'''DEBUG''' will enable debugging mode. Which outputs information to the Serial Port.
 +
 
 +
'''LED_MATRIX_PIN''' is the pin that the LED MATRIX is connected to.
 +
 
 +
'''LED_COUNT''' is the number of NeoPixels in the LED Matrix
  
6. Once the program is uploaded. The line of code in step number 3 will set the time on the Real Time Clock module. But this occurs every time the Core module starts up. Which is undesired in keep track of the time. Go back to the code and disable that line by commenting it out with '''//''' as follows. Then re-upload the program.
+
'''JOYSTICK_X_AXIS_PIN''' is the pin that the Joystick (x-axis) is connected to.
<source lang="cpp">
 
//setRtcTime(15, 5, 18, 1, 00, 00, 00);
 
</source>
 
  
==Debugging==
+
'''JOYSTICK_Y_AXIS_PIN''' is the pin that the Joystick (y-axis) is connected to.
==Tweaking==
 
  
 
=Usage=
 
=Usage=
Turn on the project and the time stored on the Real Time Clock (RTC) module will be retrieved and displayed on the OLED screen. Powering off the project will maintain the time since the Real Time Clock (RTC) has a capacitor that enables keeping track of the time even when the power source is off. (Please comment out the '''setRtcTime''' line so that the time does not get overwritten every time the Core module starts up).
+
Turn on the project and move the Joystick around in different directions to change the color of the lantern (ColorLED or LED Matrix).

Latest revision as of 00:28, 4 May 2017

Joystick Lantern Project Build

About

This project uses the Joystick trinket to change the colors of a color ColorLED or LED Matrix. Changing the direction of the Joystick will directly change the colors on the ColorLED or LED Matrix.

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

Required Materials

This project can be built in two ways. Either using the LED Matrix (202 Advanced Kit or 302 Expert Kit required) or ColorLED (302 Expert Kit required) as the color changing lantern.

202 Advanced Kit or 302 Expert Kit required

  • 1 x mCookie Core
  • 1 x mBattery (202/302 Kit)
  • 1 x mCookie Sensor Hub
  • 1 x LED Matrix
  • 1 x Joystick
  • 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 Joystick
  • 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.

  1. Connect a Joystick to the Sensor Hub on Pin A2/A3.
  2. Connect a ColorLED to the Sensor Hub on Pin A0/A1 (302 Expert Kit compatible build).
  3. Create two stacks containing:
    1. (Bottom of Stack) Sensor Hub (Top of Stack)
    2. (Bottom of Stack) Core | LED Matrix (202 Advanced Kit build). (Top of Stack)
  4. Stack the two stacks onto the mBattery
  5. 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:Joystick Lantern X02.zip.

  • Using the Microduino IDE and go to File > Open... and navigate to the unzipped folder. Open the Joystick_Lantern_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 color of the lantern will be displayed.

Tweaking

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

LED_MATRIX_PIN is the pin that the LED MATRIX is connected to.

LED_COUNT is the number of NeoPixels in the LED Matrix

JOYSTICK_X_AXIS_PIN is the pin that the Joystick (x-axis) is connected to.

JOYSTICK_Y_AXIS_PIN is the pin that the Joystick (y-axis) is connected to.

Usage

Turn on the project and move the Joystick around in different directions to change the color of the lantern (ColorLED or LED Matrix).