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:


#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!

image

References:

Saludos @ Home

El Bruno

image image image Google

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

  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.
    Thanks.

    Like

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading