Hello!
If your wife isn’t close to and you get to make the Space Cadet from your girl costume, likely that you leave a little bit of mold. In my case it was simple; Arduino, a motion sensor, led and Visual Studio 2013.
Note: I never tire of repeating how useful that is Visual Micro for creating projects.
Here’s a video of the final result, as the motion sensor “moves” being sent different values for the brightness of the led Strip. This with a 9V battery and then you have to put it in the guise of Space Cadet.
The source code is as follows:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Wire.h> | |
| #include "MMA7660.h" | |
| MMA7660 acc; | |
| int brightness = 0; // how bright the LED is | |
| int ledStrip = 6; // the pin that the LED is attached to | |
| int accelerometer = 13; // the pin that the accelerometer sensor is attached | |
| int fadeAmount = 5; // how many points to fade the LED by | |
| void setup() | |
| { | |
| acc.init(); | |
| pinMode(accelerometer, OUTPUT); | |
| } | |
| void loop() | |
| { | |
| static long cnt = 0; | |
| static long cntout = 0; | |
| float ax, ay, az; | |
| int8_t x, y, z; | |
| acc.getXYZ(&x, &y, &z); | |
| analogWrite(ledStrip, brightness); | |
| brightness = z; | |
| if (brightness == 0 || brightness == 255) { | |
| fadeAmount = -fadeAmount; | |
| } | |
| delay(30); | |
| } | |
Iimportant: only 32 lines of code!
References:
- Grove System
http://www.seeedstudio.com/wiki/Grove - Grove 3 axis accelerometer
http://www.seeedstudio.com/wiki/Grove_-_3-Axis_Digital_Accelerometer (% C2%B11.5g) - Grove Led String
http://www.seeedstudio.com/wiki/Grove_-_LED_String_Light
Saludos @ Home
El Bruno
Leave a comment