[#CODING4FUN] No more boring costumes, you only need an #Arduino, a motion sensor and a LED Strip!


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:

#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()
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;

Iimportant: only 32 lines of code!



Saludos @ Home

El Bruno

image image image Google

1 comment

  1. I will right away snatch your rss feed as I can’t to
    find your email subscription hyperlink or newsletter service.
    Do you’ve any? Kindly allow me recognize so that I may subscribe.


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: