Art, Arduino, Sound Sensors, LEDs, and Star Wars!

Regular drawing and painting just didn’t seem to fit the bill of a creative outlet for me, so I decided to design my own mix of art, Arduino, LEDs, sound sensors and star wars all sprinkled with a little computer code.  The end product is a MASSIVE (4’x5′) Star Wars art piece with lights that wirelessly dance to the beat of the music.  I hope this inspires you to build your own.

The list of supplies:

For the tech side:

IMG_0171

I got all the tech working by compiling an uploading the following code to the Arduino:


#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3

int redNow;
int blueNow;
int greenNow;
int redNew;
int blueNew;
int greenNew;

void setup()
{
pinMode(7,INPUT); //SIG of the Parallax Sound Impact Sensor connected to Digital Pin 7
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
redNow = random(255);
blueNow = random(255);
greenNow = random(255);
redNew = redNow;
blueNew = blueNow;
greenNew = greenNow;

}

#define fade(x,y) if (x>y) x–; else if (x<y) x++;

void loop()
{
boolean soundstate = digitalRead(7);
if (soundstate == 1) {
analogWrite(BLUEPIN, blueNow);
analogWrite(REDPIN, redNow);
analogWrite(GREENPIN, greenNow);
redNew = random(255);
blueNew = random(255);
greenNew = random(255);
// fade to new colors
while ((redNow != redNew) ||
(blueNow != blueNew) ||
(greenNow != greenNew))
{
fade(redNow,redNew)
fade(blueNow,blueNew)
fade(greenNow,greenNew)
analogWrite(BLUEPIN, blueNow);
analogWrite(REDPIN, redNow);
analogWrite(GREENPIN, greenNow);
delay(1);
}
}
else{
digitalWrite(REDPIN,0);
digitalWrite(GREENPIN,0);
digitalWrite(BLUEPIN,0);
}
}

Then I put all the wiring together using this schematic.

Darth

I started by tracing out Darth Vadar using a projector onto the floor under layment board.

IMG_0138

Cut out everything that was white.

IMG_0143 IMG_0142

Glue and fixed everything I broke.

IMG_0145 IMG_0146 IMG_0147

and because I’m a bit of a perfectionist, weeks and weeks of sanding, filling, sanding, cutting (again), more sanding, and fine tooth filing with a jewelers file

IMG_0177 IMG_0169 IMG_0168 IMG_0170IMG_0207 IMG_0210

Then more cutting… this time it’s the backing plate (the MDF sheet):

IMG_0203

This holds the LEDs, hides the wires, and provides structural support for the artistic front which we glue to next.

IMG_0214

Now paint the back side with the chrome paint to reflect light.

IMG_0218

LEDs were double sided taped around the outside of where I cut it out (see pic above). Paint the front with the flat black paint (I seem to have forgotten to take a pic.)  The wiring comes next following this schematic and the Arduino, sound sensor, and one of the bread boards glued to the front.  You can see I hid the wires by using a small router on the backing plate .

IMG_5935IMG_0219

Then all that left is attaching the picture hangers and cleaning up.

IMG_1020

IMG_0235IMG_0236

//www.anrdoezrs.net/am/7931805/impressions/page/am.js

Advertisements

Intro to the Arduino Board

One of my favorite quotes from Albert Einstein is:

If you can’t explain it simply, you don’t understand it well enough

So I find it stupid that Arduino tutorials would jump straight away into complicated code (called sketches in Arduino), electrical diagrams, and acronyms of complex electrical terms.  Arduinos are an awesome, cheap, and easy way of learning robotics. They’re so simple and should really be explained that way (at least initially), so in this blog post I will set out to do just that.

Overview

I’ll be explaining the Arduino Leonardo, built through Borderless Electronics, obtained through an Indiegogo campaign for a whole $9, and pictured below:

Image

While it has some advanced things that differentiate the Leonardo from other Arduino micro controllers, the big difference is that by having only a single processor they can emulate a mouse and/or keyboard.  In lay terms, you can make a keyboard/mouse that amputees/spinal injuries control without their hands, or a glove that can control a quadracopter.  Pretty awesome, huh?

Digital Vs. Analog Pins

Analog input pins( A0-A5) are on the bottom left, and the digital pins (0-13) are on the right side.  I’ve highlighted both in the below pic

Image

The difference between the two is actually so simple and is usually overcomplicated with voltage diagrams.  An Analog input is like a dimmer switch where you can control the how much light you want from a light bulb, and a Digital input is just a regular switch where output either on or off with no in between.

AREF pin

Image

The AREF pin, or Analog REFerence pin, is the what sets the maximum power (from the left side of the pic above) and every step from zero to max (scaled in sketches 0-1024).  The power is 3.3 volts or 5 volts but these can be change/converted through the use of different techniques (think resistors).

SDA/SCL pins

Image

These pins are used for communicating with other devices. For example, connecting to a lego mindstorm (example build). The SDA pin sends and receives the data between the two devices, and the SCL makes sure that data is being sent and received at the same speed.

VIN

Image

The Arduino has pins for 3.3 volts and 5 volts, but if you want to build something with more power you can use external power put into the VIN pin.  If I was going to build and RC car or the like I would be using this to up the power to the maximum (and probably blow something up)

IOREF and RST

IOREF tells whether the power supplied is 3.3  or the 5 volts, and RST is used to reset the board.

GND pin

Image

GND is for the ground and is needed always used with the power.  It’s to complete the circuit. A battery has two poles, positive and negative. Each side of a light bulb needs to be connected to each of the poles on the battery to complete the circuit and light the bulb.

Now we know what everything does it’s time to make something cool.

Building a TOR wireless router with a Raspberry Pi

Over the summer I stayed with a really close friend’s family in Dallas, and instead of buying the Mother flowers I decided to build her a wireless TOR router because she’s a bit of a conspiracy theorist (her family says that, not me), she uses a Ipad which doesn’t support TOR, and I really wanted to do something that was personal that had meaning and thought behind it.  This router will allow her to browse the net anonymously (without big brother watching), I also fully encrypted the hard drive (in case they come after her), added libre office (open source microsoft office), and even changed the wallpaper to her daughter’s debutante photo (I’ll be hearing about this if she still reads my blog.)  I hope that she actually uses it because it adds legitimacy to TOR because it’s for everyone (she is the sweetest lady, BTW) not just the intelligence community, criminals, and drug dealers.

It took me a while to gather the parts to put it together, as I went through a couple wifi adapters before I found one with the right chip set.  Once you have the right parts, installation and setup are easy using this tutorial that I used.  They used nano in the tutorials, but you can use any editor that you feel comfortable with.  I used the following parts:

Setting the Pi as an access point

I used this tutorial.  From the terminal run the following (I ssh’d into the pi from my mac) to install the software:

sudo apt-get install hostapd isc-dhcp-server

Then you need to edit the file for the DHCP server by running

sudo nano /etc/dhcp/dhcpd.conf

The change a couple lines by adding #, and then remove a # from a line so they look like this:
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

Then add this to the bottom:

subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Next, we change the interfaces by running

sudo nano /etc/default/isc-dhcp-server

changing the last line to look like this

INTERFACES="wlan0"

Then we set the wireless to have a static IP by running

sudo nano /etc/network/interfaces

making the file read like (change addresses where applicable, I did)

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0

#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

up iptables-restore < /etc/iptables.ipv4.nat

Then tell the wireless adapter it’s address by running

sudo ifconfig wlan0 192.168.42.1

Configure the Access point by a using

sudo nano /etc/hostapd/hostapd.conf

put the following into the file

interface=wlan0
driver=rtl871xdrv
ssid=Pi_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

be sure to [especially change the ssid (name of the router) and wpa-passphrase (password) and anything else that’s applicable to changes you made early or preferences.

We now need to add a line to file in the editor

sudo nano /etc/default/hostapd

pasting in the following

DAEMON_CONF="/etc/hostapd/hostapd.conf"

You now need to configure the network address by first changing another file

Run sudo nano /etc/sysctl.conf

adding

net.ipv4.ip_forward=1

then run the following to activate the file

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Finally, to make the ethernet (eth0) and wireless (wlan0) communicate, you need to run the follow commands

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

so you don’t have to manually do it everytime you reboot, run

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Now all we need to do to get the access point working is running the hostapd software using the following commands

wget http://www.adafruit.com/downloads/adafruit_hostapd.zip
unzip adafruit_hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
sudo mv hostapd /usr/sbin
sudo chmod 755 /usr/sbin/hostapd

Your access point should now be working. To have all the software start on reboot run

sudo service hostapd start
sudo service isc-dhcp-server start
sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable

Reboot you Pi by running

sudo reboot

Installing TOR

First install the TOR software using this code

sudo apt-get install tor

edit the config file by running

sudo nano /etc/tor/torrc

and paste in

Log notice file /var/log/tor/notices.log
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1
TransPort 9040
TransListenAddress 192.168.42.1
DNSPort 53
DNSListenAddress 192.168.42.1

Now we change our routing tables by running

sudo iptables -F
sudo iptables -t nat -F

Then we set-up for ssh routing in the future (I don’t want to give up a precious monitor)

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22

now when you want to ssh into the pi you have to add a -p 22 to the command. Like this

ssh -l pi -p 22 192.168.1.100

Now do the other ports

sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040

Now run the following to activate

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

The following will create log files for debugging

sudo touch /var/log/tor/notices.log
sudo chown debian-tor /var/log/tor/notices.log
sudo chmod 644 /var/log/tor/notices.log

Finally, we start TOR manually running

sudo service tor start

Then make it start on every reboot

sudo update-rc.d tor enable

You’re done! You should now be able to connect to TOR wifi using the ssid and passphrase you used early.

The final product is about half the size of a normal router and looks like this:

photo 2

*I was going to post a pic of the desktop (with the debutante photo) but I decided that I value my life… hahhahaha

QED

 

 

-update

I did some speed testing on the router last night, and I discovered that you end up with about 25% of the speed that you would through regular wifi.

 

DIY Directional Wifi Antenna Booster

While living in Thailand, I rented an apartment where the internet wasn’t provided thinking it would be easy to get on my own.  Boy was I wrong.  Internet was around $150 to start, $100 a month, required a 12 month contract, and you needed a Thai ID (back in 2007), so I went looking for other options. I came across this site and decided to build my own wifi antenna booster out of a chinese spoon, so I could then get wifi from the bigmac shop down the street for free.

The parts were relatively cheap ($50 in all), and most of that expense was in the usb dongle.  My parts list included:

usb dongle

baby bottle (it rains HARD in the tropics)

usb cable (with amplifier if over three feet)

wire cutters (any will do)

Electrical Tape

Silicone Waterproof Sealant

craft plastic mesh(to center in the baby bottle)

Asian wire spoon

IMG_0960

The hardest part of the build is figuring the out the exact the placement of the antena in the spoon.  First you need to find the exact spot of the antenna in the dongle so you can place it right at the focal point of the spoon( I think I actually took off the plastic case to solve this mystery.)  Next you need to find the focal point of the spoon by using Cartesian equation (f=D^2/(16c)) or the square of the diameter divided by 16 times the depth of the spoon. The rest is easy, cut a hole the size of the bottle, put the usb cable through the nipple of the bottle till the distance is right at the focal point and tape the nipple to the wire, and put it all together.  I ended up taping it to my mop handle and leaving it on my balcony railing.

IMG_0962IMG_0961

and the finished product:

IMG_0963IMG_0966

It worked amazingly, I was able to not only get Wifi from the burger spot down the road, but I was also able to get signals from the high rise 1km away.  Here is a pic from in front of my building to illustrate how far it was to the end of the street where the signal was coming from:

Screen Shot 2013-02-01 at 7.17.13 PM