Tuesday, June 11, 2013

Build your own automated candy machine Part 1.5 Hardware, Arduino

Since we did the first post how to build a candy machine we have moved from using a phidget to use a small Arduino. By using a Arduino we do not need any special software to get it working and only send a simple command over a regular serial port.

We are using a Pro Micro 5v/16MHz from Sparkfun, any small size arduino running on 5v should do. Connect wires to GND, RAW for power and pin 3 for signal. Using the Vcc pin will draw to much power and make the Arduino restart endlessly.


Use double sided adhesive tape to attach the Arduino.  




Clone the git repo https://github.com/evilmachina/giveawaycandy.git or download the ino directly candyServo.ino
Upload the candyServo.ino to the Arduino and test it by connect serial monitor to it and send "give".
Depending on the servo you may need to trim for how long it should spin.

Happy hacking!
Marcus



Monday, June 10, 2013

Realtidskoppla webben med den fysiska världen @ lat55

Föreläsning och demo om "Realtidskoppla webben med den fysiska världen" av Marcus på lat55


Koden exemple från demo finns:
 https://github.com/everymote
 https://github.com/evilmachina


Happy hacking!



Monday, June 3, 2013

Use #RaspberryPi CSI camera module to stream live video to Bambuser

The new CSI camera module for the raspberry pi make it posible to stream high-definition video without having problem with performance. Streaming with ffmpeg will use about 2-4% and raspivid 1-2% of the CPU.



I am using Adafruit Occidentalis distro that is build on raspbian.
Start by upgrade the Raspberry Pi firmware and install the camera module

sudo apt-get update
sudo apt-get upgrade
sudo raspi-config

Enable the camera

Enable Camera
Enable the camera

More information on how to install the camera module http://www.raspberrypi.org/archives/3890

First ffmpeg need to be removed and install from source. The reason for this is that the package distributed through apt-get is not compiled with H264 suport.
Compiling the code takes a few hours so start it in a screen so it do not stop if losing connection to the pi or do a cross compile.
To use screen

sudo apt-get install screen
screen
Compile and install ffmpeg

sudo apt-get remove ffmpeg
cd /usr/src
sudo mkdir ffmpeg
sudo chown `whoami`:users ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure
make
sudo make install

Now it is time to get your stream url and key from Bambuser https://bambuser.com/api/keys

raspivid -t 9999999 -w 960 -h 540 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -metadata title="Streaming from raspberry pi camera" -f flv [url]/[id]

If the image need to be flipped or mirrored -hf and -vf can be use on the raspivid command.

-hf, --hflip    : Set horizontal flip
-vf, --vflip    : Set vertical flip

Now you should be able to se the video on your Bambuser dashboard


This will likely be work with other streaming services as ustream and justin.tv

Happy hacking
Marcus