Monday, May 31, 2010

Third Annual Experimental Garage Sale

Experimental Garage Sale 2010, June 5th. Noon-5PM
At the Experimental Sound Studio
 5925 N Ravenswood, Chicago, IL 60660 (map) 773-769-1069

Circuit Bent Instruments, Un-Bent Gear, Parts, Vintage Components, Guitar Pedals, Custom Lamps, GetLoFi Kits, and More! WITH SPECIAL DRAWING AT 3:00 PM!! Prizes include custom devices and electronics kits from the Midwest's premier experimental electronics artists including Roth Mobot, Talking Computron, Reed Ghazala, and MORE!
10 Sellers!
  1. Tommy S. rothmobot.com 
  2. Patrick M. rothmobot.com 
  3. Mike aa9il.com 
  4. Steve site.properboy.com 
  5. thejunkyard catalist myspace.com/ThriftsoreBoratorium 
  6. Creme Dementia myspace.com/CremeDeMentia 
  7. GetLoFi.com getlofi.com 
  8. Low-Gain lowgain-audio.com 
  9. Tim Kaiser htimkaiser.org 
  10. Buck stevenbuck.us/
More Info:
http://www.gelofi.com
http://www.experimentalsoundstudio.org/

Wednesday, May 12, 2010

Arduino / Hacked Toy Internet Alert Circuit

Overview
Zach Kaplan recently invited Roth Mobot to the Chicago offices of Inventables to lead their monthly Lab session wherein guests speak about the various recent crossovers of technology and creativity. At first we were asked to conduct a hands-on toy hacking session with Inventables' employees, but about a week before our arrival we were given the circuit bending challenge of creating an "interface between the Internet and a common circuit bent toy."

Basic Data Flow
We decided to create a circuit that would activate a toy whenever someone logged into Roth Mobot's web site. We designed a simple and elegant solution using an Arduino, a homemade Vactrol, a common electronic toy, and three simple scripts written in different programming languages. We'd like to thank William Swyter for lending us his Arduino, and Factory Smoke for his Vactrol suggestion, which stopped us from creating overly-complicated custom circuitry with transistors and diodes, and made the programming a piece of cake. The result was an elegant circuit that electrically insulates the toy from the Arduino (and the computer) by "optically coupling" them with light.
 
Vactrol Construction
We've included a diagram of how to build a Vactrol. All you need is a bright LED, and a Cadmium Sulfide photo resistor. We used black epoxy for our casing.

Arduino / Vactrol Hook Up
We plugged the Vactrol's LED's ground lead into the Arduino's ground socket, and it's positive lead into the Arduino's number 13 socket. We used socket number 13 because it has a built in resistor.

Vactrol / Hacked Toy Hook Up
We then connected the two leads from the Vactrol's photo resistor to two leads coming out of a hacked police truck toy. The beauty of this approach is that it doesn't matter what the voltage of the toy is or whether it's "voltage triggered" or "ground triggered."

Video of Circuit in Action
Now when someone logs into our web site the circuit bent police truck toy lights up and says, "Slow down, pull over!" in a demonic voice.


Sample PHP  Code 
We embedded this common basic hit counter in our home page
<?php  $count_my_page = ("hitcounter.txt"); 
$hits = file($count_my_page); 
$hit = trim($hits[0]); 
$hit++; 
$fp = fopen($count_my_page , "w"); 
fputs($fp , "$hit"); 
fclose($fp); 
echo $hit; 
?>;
 
Sample Python Code 
This is the Python script that runs on the computer attached to the Arduino and the hacked toy. It requires the PySerial library extension to be installed. The only part of the code we had to change was the Arduio's serial port and the location of the TXT file being generated by the PHP script on our server. (highlighted below). 
# fetch txt file

import time
import urllib
import serial

# USB serial connection to Arduino

ser = serial.Serial(
   'com4', 115200)
myUrl = 'http://www.YOURWEBSITE.COM/hitcounter.txt'

last_counter = urllib.urlopen(myUrl).read()
while (True):
  counter = urllib.urlopen(myUrl).read()
  delta = int(counter) - int(last_counter)
  print "counter: %s, delta: %s" % (counter, delta)
  ser.write(chr(ord(chr(delta))))
  last_counter = counter
  time.sleep(10)

Sample Arduino Code 
This code was originally used to activate a servo motor. We Frankensteined it with some other code to light the Vactrol's LED. 
int ledPin = 13; 
int minPulse = 0; 
int maxPulse = 10; 
int pulse = 0; 
int rings = 0; 
long nextMillis = 0; 
long lastPulse = 0; 
int refreshTime = 200; 
int state = 0; 
 
void setup() {
  pinMode(ledPin, OUTPUT); 
  pulse = minPulse; 
  Serial.begin(115200);
}

#define PULSE_ON       0
#define WAIT_PULSE_ON  1
#define PULSE_OFF      2
#define WAIT_PULSE_OFF 3
 
void loop() {
  
  if (Serial.available() > 0) {
    rings += Serial.read();
    Serial.println(rings);
  }
   
  if (rings > 0) {
      digitalWrite(ledPin, HIGH);  // LED on
      delay(200);                  // wait
      digitalWrite(ledPin, LOW);   // LED off
  }
  if (rings = 0) {
      digitalWrite(ledPin, LOW);   // LED off
  }
  }