Category: Arduino

PoetBot!

 

For this project, I wanted to make a machine that took numerical input and produced something creative out of it. I was inspired by John Keats’ poem “This Living Hand” (which can be found in my Processing code), which deals with the life of the poet/resurrection of the poet when you read his work. I like the idea of having a machine that creates art, and since I wanted to incorporate Twitter, I decided to make a robot that writes poetry and tweets it at the push of a button. After some googling, I discovered Rita (link here), a library that can be used to intelligently parse English words/sentences. Then, I used the Gutenberg Project (link here) as well as other online poetry resources to collect .txt files filled with poetry: Shakespeare’s sonnets, Keats’ odes (+ “This Living Hand”), “Nothing but Death” by Pablo Neruda, and some works by Poe and a Russian poet named Marina Tsvetaeva. I chose them because they are my favorites, and they are very typically flower-y poets, with lots of emotional and figurative content, an interesting contrast when coming from a machine. I also used Twitter4J and learned heavily from the examples Golan posted on the EMS website.

There are two main components to my project: the Arduino code and the Processing code. The Arduino part is very simple; it detects when the button is pushed and prints the amount of electromagnetic interference (from 0-1023) to the Serial monitor. The Processing code takes the printed value, grabs a grammatically correct sentence comprised of words from the .txt files, and, according to the EMI, scrambles the sentence into a more jumbled sentence (as if it were being confused by all the interference). To randomize the sentence, each time it runs through the Randomize function, it does any of a number of random changes (reversing, shortening, adding random characters). The higher the EMI, the more scrambled the sentence becomes. Then, once it’s done scrambling, it tweets the resulting sentence to my Twitter account.

(side note: I’d like to make this wireless by adding a wifi shield, but I wonder if the wifi would mess with the EMI. Only one way to find out, so I’m gonna try it over break.)

Pics:

 

This is a window that opens in Processing when running the sketch, it has instructions on the first line, the un-randomized poem on the second line, and the final, Tweeted poem on the third line.

The video is coming soon, though it’s not very interesting to watch (just me pushing the button and refreshing the Twitter page so you can see that it Tweeted). I’m having some issues getting it off my phone.

To see the poetry the PoetBot has tweeted, see here: https://twitter.com/EMIpoetry

Here’s the Fritzing diagram:

Here’s the Arduino code, for measuring the EMI:

(it has some commented-out print statements for debugging still in it.)

const int  buttonPin = 8;    // the pin that the button is attached to
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button (0 or 1)
int lastButtonState = 0;     // previous state of the button (0 or 1)

int emiInPin = 5; //this pin measures the EMI using a partially exposed wire
int val = 0;

void setup()
{
  //receive data from button (digital) or wire (analog)
  pinMode(buttonPin, INPUT);
  pinMode(emiInPin, INPUT);

  //initialize serial communication, for debugging purposes:
  Serial.begin(9600);
}

void loop()
{
  buttonState = digitalRead(buttonPin); //read current state of button (1 or 0)
  val = analogRead(emiInPin); //read input from wire

  if (buttonState != lastButtonState) { //button state changed (button was pressed)
    if (buttonState == HIGH){ //button was turned on, pay attention to info from wire
      //Serial.println("button on!");
        Serial.println(val);
    }

    if (buttonState == LOW){//button was released, we don't care about that event
      // (we only care about triggering an event when the button is pressed,
      //  not the actual state of the button)
      // this line is actually kind of useless, but I like to include it for clarity.
      //Serial.println("button off!");
     }
    lastButtonState = buttonState; //save the button state
  }
}

 

And here’s the Processing code, for receiving the signal from Arduino, making a tweet, and tweeting it:

/*
 andrea gershuny
 carnegie mellon university, electronic media studio II
 fall 2012, section A w/ Golan Levin

 based on code by Golan Levin:
 processing_to_twitter processing sketch, Modified from
 visit <http://www.instructables.com/id/Simple-Tweet-Arduino-Processing-Twitter/>
 visit <http://www.twitter.com/msg_box>

 this reads input from the arduino that indicates the electromagnetic interference (EMI),
 uses a library called rita to generate a gramatically correct (but not necessarily semantically correct)
 sentence from texts by Keats, Shakespeare, Neruda, Tsvetaeva, and Poe, mixes that senteces up,
 and tweets it. (The more EMI, the more the poem gets mixed up.)

 for fun, here is my favorite poem, "This living hand, now warm and capable",
 by John Keats, written 1819-1820:

 This living hand, now warm and capable
 Of earnest grasping, would, if it were cold
 And in the icy silence of the tomb,
 So haunt thy days and chill thy dreaming nights
 That thou would wish thine own heart dry of blood
 So in my veins red life might stream again,
 And thou be conscience-calm’d–see here it is–
 I hold it towards you.

 */

import processing.serial.*;

import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.http.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;

import rita.*;

int MAX_LINE_LENGTH = 140;
String data = "http://rednoise.org/rita/data/";
String chars = "q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,;,.,,:,~,`,"; //chars to mess the tweet up with
static int charsLen = 60; //length of chars string

RiText rts[];
RiMarkov markov;

//these are my twitter keys, please don't steal them or be a dick or anything.
static String OAuthConsumerKey    = "BdKQbq82hpjkS6l45pDqVQ";
static String OAuthConsumerSecret = "38yctkzoONdGwZfpPABEytdhtWsPhjzlrldqPdkJvJc";
static String AccessToken         = "988448905-jiP8Seol9Ttp9qK59hdg5c15CHHN4ZJxsoWbRKUq";
static String AccessTokenSecret   = "A8udnwBIDh1u3OM2fTTO3Rp9ftKVK9ZNGDibKwv3hJI";

Serial arduino;
Twitter twitter = new TwitterFactory().getInstance();

String prevUnmodifiedPoem = "";
String prevModPoem = "";

void setup() {
  size(700, 150);
  loginTwitter();

  markov = new RiMarkov(this, 3);  //model that tokenizes based on whitespace characters

  println(Serial.list());
  String arduinoPort = Serial.list()[0];
  arduino = new Serial(this, arduinoPort, 9600);
  arduino.bufferUntil('\n');

  /* load some text files for processing to pull from:
   (1) Shakespeare's sonnets (was going to use Hamlet but Hamlet's name was distracting)
   (2) some poems by John Keats (his odes + "This Living Hand"
   (3) "Nothing but Death" (also known as "Only Death") by Pablo Neruda
   (4) some works by Edgar Allen Poe
   (5) some poems by Marina Tsvetaeva
   */

  markov.loadFile("shakespeare.txt");
  markov.loadFile("keats.txt");
  markov.loadFile("neruda.txt");
  markov.loadFile("poe.txt");
  markov.loadFile("tsvetaeva.txt");
}

void loginTwitter() {
  twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
  AccessToken accessToken = loadAccessToken();
  twitter.setOAuthAccessToken(accessToken);
}

private static AccessToken loadAccessToken() {
  return new AccessToken(AccessToken, AccessTokenSecret);
}

void draw() {
  background(#E3DFC7);
  fill(0,0,0);
  text("// Hit the button and I'll write you a poem.", 20, 45);
  text(prevUnmodifiedPoem, 20, 70);
  text(prevModPoem, 20, 95);
}

void keyPressed() {
  String poem = markov.generateSentence();
  println(poem) ;

  postMsg (poem);
  delay(12000);
}

void serialEvent(Serial arduino) {
  String inString = arduino.readStringUntil('\n');
  int arduinoMsg = 0;
if (inString != null) {
    // trim off any whitespace:
    inString = trim(inString);
    arduinoMsg = int(inString);
    println(arduinoMsg);

    String poem = markov.generateSentence();
    prevUnmodifiedPoem = poem;
    String msg = randomize(poem, arduinoMsg);
    prevModPoem = msg;
    postMsg(msg);
    delay(12000);
  }
}

String randomize(String poem, int emiVal) {
  String[] list = split(poem, " ");
  //println(list);
  int changes = 0; //keeps track of how many changes we've made to the poem
  while (changes < emiVal) { //number of changes we'll make is based on EMI
    int change = int(random(3)); //determines which change we'll make this pass

    if (change==0) {
      list = reverse(list);
    }

    if (change==1) {
      list = sort(list);
    }
    if (change==2) {
      list = shorten(list);
    }
    if (change==4) {
      list = appendRandom(list);
    }

    if (change==3) {
      list = spliceRandom(list);
    }

    changes ++;
  }
  poem = join(list, " ");
  return poem;
}

String[] appendRandom(String[] list) {
  int randomLen = int(random(1, 7)); //random length of string to append
  int randomInd = int(random(1, 60)); //random index
  // String[] charsList = chars.split(",");
  String toAppend = chars.substring(randomInd, randomInd+randomLen);
  String[] list2 = append(list, toAppend);
  return list2;
}

String[] spliceRandom(String[] list){
 int randomLen = int(random(1,7)); //random length of string to splice
 int randomInd = int(random(1,60)); //random index
 int index = int(random(0,5)); //6 words is minimum length of sentence; this index is where we'll splice in
 String toSplice = chars.substring(randomInd,randomInd+randomLen);
 String[] list2 = splice(list, toSplice, index);
 return list2;
 }

void postMsg(String s) {
  try {
    Status status = twitter.updateStatus(s);
    println("new tweet --:{ " + status.getText() + " }:--");
  }
  catch(TwitterException e) {
    println("Status Error: " + e + "; statusCode: " + e.getStatusCode());
  }
}

Rosey Denton Final Project

Description:

For my final project, I initially decided that I wanted to do something with lasers and making some kind of nice looking light show. I bought a laser, some mylar, and a couple sheets of refraction grating. Unfortunately the grating was a little disappointing and only split the laser into a couple spread out beams. The mylar, however, had a really nice reflective quality to it that I wanted to experiment with. I made a few half-bubbles with sheets of mylar and some wire and first hooked one up to a motor to spin around. but something about that wasn’t really enough. I then took more of the bubbles I had made and strung them together with stretchable string. I tied it to a servo with an extended arm and it pulled the mylar in kind of a nice way. I then ended up attaching 3 half bubbles together to form a clam-like thing that subtly opens and closes which changes how the reflections look as the mylar is pushed and pulled. In general, I just like making things that look nice in some way or another. While I’m still not great as a crafter, I feel like with more and more practice I can give better life to more of my visual ideas and would really like to come back and work with mylar again sometime since it takes light so nicely.

Pictures:

Video: 

Fritzing:

Code:

#include 
Servo servo1;

void setup(){
  servo1.attach(10);
}

void loop(){
 int position;
 for(position = 0; position < 180; position += 2){
    servo1.write(position);      
    delay(100);}     
 for(position = 180; position >= 0; position -= 1){
    servo1.write(position);  
    delay(100);              
  }
}

Michael Importico – Final Project – Aether Artifact

This work is about creating the illusion of picking up radio waves from the past.  I Created the audio track from shortwave radio recordings mixed with old time radio dramas and Rachmaninov’s Prelude in G.  The title of the work is very important because it relies on a set of beliefs in a disproved physics theory – Aether.  In the recent past, Aether was everything that wasn’t.  It was responsible for holding the planets in place in the cosmos.  It was also responsible for the transmission of electro-magnetic waves – this is the capacity of it’s history I am choosing to exploit for my work.

Technologically, I am running my audio signal from an external MP3 player into the arduino, and treat it like a sensor reading.  Then I mapped the audio peaks from this information to the modulation of the LED, allowing it to blink in unison with the audio.

 

 

const int volPin = 0; // sensor in - analog audio input
const int ledPin = 9; // my led output pin

void setup() 
{ 
  Serial.begin(9600); // Use the serial monitor window to help debug our sketch:
} 


void loop() 
{ 
  pinMode(ledPin, OUTPUT); //sets ledPin to output
  
  int decible;    // Input value from the analog pin.  not really a decible.. just a name
  int ledBright;  // this will carry my mapped LED brightness


  decible = analogRead(volPin); //
  ledBright = map(decible, 0, 25, 0, 255); //this scales my volume to my LED brightness

  Serial.print("Volume: "); //Output to serial monitor
  Serial.println(decible);  // used to help me map my volume to the LED brightness

  analogWrite(ledPin, ledBright);

  delay(20);
} 
 


 

 

Firewall

Premise:

You are a computer’s firewall. Anonymous has sent an army of misfit infected floppys lose on the interwebs in an attempt to put viruses on to your server!!! You can’t destroy the floppys directly because you do not know where they are located, you must instead use their viruses against them! You can shoot down viruses directly with your security defense, but it will do you little good because the floppys will continue to send you viruses. Don’t let the viruses reach your critical data! Watch out for Anonymous as they will randomly fly by to inspect that their floppy army is doing their job, if you can shot down Anonymous’ surveillance you get bonus points!!

Gameplay Video:

Proposed Location: Arcade

Hardware Used: Arduino Uno, Gameduino, Joystick Shield

No Fritzing diagram needed, just buy the two shields and stack them in the only way possible ;)

Helpful Links:

  • http://excamera.com/sphinx/gameduino/
  • http://answers.gameduino.com/questions/
  • http://gameduino.com/tools/
  • http://www.altdevblogaday.com/2011/07/11/let-me-introduce-you-to-gameduino/
  • http://artlum.com/gameduino/gameduino.html
  • http://www.kickstarter.com/projects/2084212109/gameduino-an-arduino-game-adapter

Possible Expansion: Gameduino Portable

No this doesn’t actually exist sadly. But I could make it, I would require a screen and power supply. The power supply for the Arduino is easy, a 9V battery! The power supply for the screen could be tricky depending on the screen. Because the Gameduino outputs 300×400, I would want a screen with such resolution which get rids of the screen meant for Arduino’s that can be found at Adafruit. The best screen I could find would be the one that was used in the original Playstation Portable (PSP) that SparkFun sell: https://www.sparkfun.com/products/8335

The problem of power supply still remains, but the fact that it was used in a portable game system makes it seem very likely that I could figure out a way to make it work. I would then laser cut a box to hold the components (I image it would take the shape of a netbook, I would use hinges and make it so that you could flip it closed). Place in the Arduino Sandwich (Arduino Uno, Gameduino, Joystick Shield), the screen, a 9V in an easy to access spot and the screen’s power supply. AND BOOM! I would have my very own portable game system!

The Code:

The code for the game is rather long so I thought it would be silly to just copy and paste here, because it would be unorganized and you would be scrolling for ages!

It can instead be view @: http://games.itbmac.com/firewall.zip

 

Stephanie – LED Shirt

My final project was to sew a shirt that had RGB LEDs on the sleeves whose flashing modulation could be controlled by three buttons in the palms.

Since the final presentations on Wednesday I’ve finally mastered the pin mapping, and now each button corresponds to a different mode of flashing on your arm.

When the project was announced I knew I wanted to make something wearable with RGB LEDs. I started out thinking about making an armored gauntlet that glowed, but the idea soon grew into an entire shirt covered with LEDs. I bought a Lilypad Arduino from Sparkfun to control the LEDs, but realized too late that it did not have enough I/O pins to control all of them. Looking back I could have tried out individually addressable LEDs, but I think the ones I used look nicer.

Since my LEDs were not individually addressable this meant I needed a ton of I/O pins to control them. I had thirty LEDs on my strip and I cut it into ten short strips of three lights each. Five segments would go on each arm, and each segment needed four wires to control the lights. This meant I needed about 40 I/O pins just to power the LEDs, and not including the buttons I’d use to control them. My Arduino and Lilypad didn’t have nearly enough I/O pins, but my dad had a ChipKit Max 32 lying around from a previous project of his that he lent me. (He’s an electrical engineer at NASA so he often gets stuff like this for fun.) The ChipKit is a pretty amazing board. It has a whopping 83 I/O pins and built in Ethernet capabilities. Adafruit and Sparkfun don’t have them, but they can be ordered here:
http://www.digilentinc.com/Products/Catalog.cfm?NavPath=2,892&Cat=18
The data sheet that I referenced for the pin mapping is here:
http://www.digilentinc.com/Data/Products/CHIPKIT-MAX32/chipKIT%20Max32_rm.pdf
It requires a different programming environment than Arduino, but it works in exactly the same way. Much like how Arduino is similar to Processing.

Each LED segment is soldered on to a piece of ribbon cable, which was easily attached to a 2×17 pin connector that could easily be plugged in and taken out from the ChipKit. Five of the ribbon cable wires needed to be dedicated to the button panels on the palms of the sleeves; 1 power, 1 ground, and 3 signal. The actual button panels were salvaged/cannibalized from a dead Sony VCR and came already-soldered with the correct resistors.

Unfortunately, Fritzing has no support for the ChipKit and doesn’t seem to know what ribbon cable is either. But here is a general idea of what the wiring for one arm would look like:

And an actual picture of the connectors to the ChipKit. The (barely visible) diodes are for providing the correct voltage drop when the LEDs are plugged in but unlit.

Sewing the shirt out of spandex only took me a few minutes, but attaching the LEDs to the sleeves took way longer. The stiff wires would stretch the fabric in ways that made it difficult to sew, and the adhesive on the back on the LED strips was no help whatsoever. In order to keep the pins on the bottom of the ChipKit from poking me in the back, and to make the garment (theoretically) washable I attached velcro to the bottom of the control board and stuck it to a panel of craft foam I sewed on to the back of the shirt.

Altogether, I’m really happy with how this project turned out. I learned a lot about pull-down resistors, pin mapping, and the wonders of ribbon cable. I also figured out how to sew a shirt out of spandex and learned a new soldering technique from my dad. The design of the electronics was well executed but I wish there was a better way of attaching the LEDs to the shirt because they stick out at awkward angles sometimes. I’m also really pleased with the way the light travels up and down the sleeves when the buttons are pressed. It would have been cool to use PWM to fade them, but there are only five PWM pins on the board. Not to mention that it would involve heavy alteration of my existing design to incorporate them.

I’ve been talking with a friend of mine about possibly getting a pair of these shirts exhibited in a rave runway fashion show he is planning. He’s very enthusiastic about featuring them and it’s an exciting idea, but if I were to do that I would have to think about streamlining the integration of the electronics into the fabric and deal with the issue of battery life. Currently this piece eats a 9V battery every 10 minutes or so when it’s not plugged in to the wall.

In the future I’d love to make more of these with higher durability and more light control options for performances and dancing.

Code

int ledString1L[] = {  // string 1 green/red/blue J3/J14
  44, 84, 83};

int ledString2L[] = {  // string 2 green/red/blue J3/J14
  13, 82, 12};

int ledString3L[] = {  // string 3 green/red/blue J3/J14
  11, 80, 10};

int ledString4L[] = {  // string 4 green/red/blue J3/J14
  9, 78, 8};

int ledString5L[] = {  // string 5 green/red/blue J3/J14
  7, 76, 6};

int ledString1R[] = {  // string 1 green/red/blue J8/J9
  23, 22, 25};

int ledString2R[] = {  // string 2 green/red/blue J8/J9
  30, 28, 29};

int ledString3R[] = {  // string 3 green/red/blue J8/J9
  31, 32, 33};

int ledString4R[] = {  // string 4 green/red/blue J8/J9
  35, 36, 37};

int ledString5R[] = {  // string 5 green/red/blue J8/J9
  39, 40, 41};

const int button1RPin = 53;
int button1RState = 0;

const int button2RPin = 52;
int button2RState = 0;

const int button3RPin = 51;
int button3RState = 0;

const int button1LPin = 70;
int button1LState = 0;

const int button2LPin = 0;
int button2LState = 0;

const int button3LPin = 1;
int button3LState = 0;

void setup() {                
  // initialize the digital pin as an output.
  int i;
  for (int i = 0; i < 3; i++) {
    pinMode(ledString1L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString2L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString3L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString4L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString5L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString1R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString2R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString3R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString4R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString5R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  pinMode (button1RPin, INPUT);
  pinMode (button2RPin, INPUT);
  pinMode (button3RPin, INPUT);

  pinMode (button1LPin, INPUT);
  pinMode (button2LPin, INPUT);
  pinMode (button3LPin, INPUT);

}
void loop() {
  button1RState = digitalRead(button1RPin);
  if (button1RState == HIGH) {  
    int del=50;
    for (int i = 0; i++) {
      digitalWrite(ledString5R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3  ; i++) {
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
button2RState = digitalRead(button2RPin);
  if (button2RState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3  ; i++) {
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
 button3RState = digitalRead(button3RPin);
  if (button3RState == HIGH) {  
    int del=10;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);    // set the LED on
      delay(del); 
    digitalWrite(ledString1R[i], HIGH);
    }
  }
  else{
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
  }
button1LState = digitalRead(button1LPin);
  if (button1LState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }

   button2LState = digitalRead(button2LPin);
  if (button2LState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }

  button3LState = digitalRead(button3LPin);
  if (button3LState == HIGH) {  
    int del=30;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);    // set the LED on
      delay(del); 
    digitalWrite(ledString1L[i], HIGH);
    }
  }
  else{
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
  }
}

Stephanie and Minnar – Jellyfish

Our project is a mechanical jellyfish whose tentacles scrunch as it bobs up and down. The top is a wire armature with fabric wrapped around it, and the tentacles are acetate plastic strips that have been hand cut and laser cut. Clear fishing line connects the tentacles and suspends the jellyfish from a stepper motor that controls its vertical movement. Some fishing line runs from the top of the jellyfish up to two ball bearings, the stepper motor, and a counterweight. The rest connects the tentacles together and is anchored to the bottom of the wooden frame structure. Pulling the string upwards pulls our tentacles upward, causing them to scrunch.
We were inspired by this youtube video and by the movements of real jellyfish. http://www.youtube.com/watch?v=JAULjWIwJBg
We wanted to create a puppet that would elegantly mimic the gestures of a jellyfish with only one motor. First we fabricated a small, non-motorized prototype to experiment with how to best execute the gesture of the tentacles, then worked on how to bring it to life with Arduino. Using a servo motor would have been easy, but we were turned off by the loud squeaky sounds that they make. We experimented with muscle wire as a means to pull our jellyfish up, but it was difficult because muscle wire only shrinks 3-5% of its length. Instead we chose to use a stepper motor, and went through several before we found one that was powerful enough to raise and lower the jellyfish. Adding the on/off switch was also a challenge because we were unfamiliar with the circuitry of the stepper motor. Luckily, we got a lot of great advice from Ali Momeni and Robb.

We went through several sketches before arriving at our final design.

Code:

#include 

// Map our pins to constants to make things easier to keep track of
int pushButton = 7;
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
boolean forward = true;

// The amount of steps for a full revolution of your motor.
// 360 / stepAngle
const int STEPS = 500;
int currentStep = 0;

// Initialize the Stepper class
Stepper myStepper(STEPS, dirA, dirB);

void setup() {
  // Set the RPM of the motor
  myStepper.setSpeed(8);

  // Turn on pulse width modulation
  pinMode(pushButton, INPUT); 

  pinMode(pwmA, OUTPUT);
  digitalWrite(pwmA, HIGH);
  pinMode(pwmB, OUTPUT);
  digitalWrite(pwmB, HIGH);
  // Turn off the brakes
  pinMode(brakeA, OUTPUT);
  digitalWrite(brakeA, LOW);
  pinMode(brakeB, OUTPUT);
  digitalWrite(brakeB, LOW);

  Serial.begin(9600);
}

void loop() {

  if (digitalRead(pushButton)==1){
    Serial.println ("steppin'!");

    if(forward){
      myStepper.step(1);
      currentStep +=1;
    } else {
    myStepper.step(-1);
    currentStep +=1;
    }

    if (currentStep == STEPS){
      forward = not forward;
      currentStep = 0;
    }
  }
}

Note: Fritzing does not have support for the Arduino motor shield we used.

Assignment 10 – Rosey and Connie

Our project started as an idea to see how light could be altered by clear shapes moving around it. We wanted to have a series of gears that would turn and move around strings of clear shapes in interesting ways. One of the earlier problems we encountered was the positioning of the gears, which unfortunately made us reconsider the design and just put them along the top of the box instead of all over just so we knew they would work consistently. The next problem we had was simply being able to make at the gears turn with only one motor. Though we began developing a solution, it was brought to our attention that we would have probably needed another layer on top of our current one to hold everything in place and would need something stronger like a rubber band to rotate everything. Despite these mechanical issues, I do believe that we have made a satisfactory prototype of a light-based work especially when it is viewed in the dark. I am proud of the starburst effect that emits from the box due to the strands of clear shapes and I like that it almost looks like a water-reflected surface when the gears do rotate. Overall, I feel like while we had our share of construction issues while making this project, it was definitely not a waste and rather something that we learned a lot from with some level of success.

EMS documentation from Rosey Denton on Vimeo.

Oliver and Michael – Automaton

Our goal for this project was to give our automaton less than admirable human qualities juxtaposed against a desperate will to survive and be free. Our hopes were to capture the gesture of the struggle to free oneself from a straight jacket. As we head towards artificial intelligence with great advances in computing technology and science we began to question if artificial emotion will be developed as well. Is it possible to an intelligent computer to have emotional or mental sickness?

We created this automaton using two servo motors attached to laser-cut wooden framework and gears. It wears a hand-sewn straight jacket to constrain its motion. The figure is attached to a metal box with an on-off switch on the outside and all of the wiring, the Arduino, and the breadboard inside.

The automaton’s movement has three stages: frantic motion, reserved motion, and rest. The servo angles and delay times use a constrained randomized method to simulate struggle.

 

Photos:

   

 

Video:

[youtube http://youtu.be/-bNvmn04A_Q]

 

Fritzing diagram:

 

Code:

// less than and greater than signs messed up the code on this 
// blog post so I had to spell out "is less than" and 
// "is greater than"

#include Servo.h

Servo servo1, servo2;
const int buzzerPin = 4;
const int franticReps = 18;
const int reservedReps = 7;
int position;

void setup() {
  servo1.attach(8);
  servo2.attach(9);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  int m=0;
  // frantic motion
  while (m is less than franticReps){
    franticMotion();
    m++;
  }
  // reserved motion
  int n=0;
  while (n is less than reservedReps){
    reservedMotion();
    n++;
  }
  // rest
  delay(random(8000,10000));
}

void reservedMotion() {
  for(position=40; position is less than 140; position+=4) {
    // shoulders
    servo1.write(position);
    // elbows
    servo2.write(position);
    delay(30);
  }
  for(position=140; position is greater than 40; position-=4) {
    // shoulders
    servo1.write(position);
    // elbows
    servo2.write(position);
    delay(30);
  }
}

void franticMotion() {
  // shoulders
  servo1.write(random(20,60));
  // elbows
  servo2.write(180);
  delay(random(200));
  // shoulders
  servo1.write(random(120,160));
  // elbows
  servo2.write(0);
  delay(random(200));
}

Luo Yi Tan – Hallowuino

I made a horrifying ghoul for halloween, using a box, leds, servos, ping pong balls, vampire teeth and an arduino.

There is a photoresistor in its nose, which detects the amount of light in the environment. When the lights are off, the servos twitch at random angles to move the eyes and mouth. I used the autotune function from the circuit 6 in the SIK book so I didn’t have to calibrate it in different lighting environments.

Video of it in action:

[flickr video=8148307250 secret=351dfe9dff w=400 h=225]

 

Here’s a diagram of my circuit:

and my code:

#include 
Servo servo1, servo2, servo3;  // servo control object
int pos1 = 0;
int pos2 = 0;
int led1 = 11;
int led2 = 6;
int input = 3; 

int period = 500;
int sensorVal = 0;
unsigned long lastDidItTime = 0;
int high = 0, low = 1023;

void setup()
{
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(input, INPUT);
  servo1.attach(9);
  servo2.attach(10);
  servo3.attach(3);
  Serial.begin(9600);
} 

void loop() {
  sensorVal = analogRead(A0);
  autoTune();
  unsigned long presentTime = millis();
  Serial.println(sensorVal);
  if(sensorVal > 0){  
    unsigned long elapsedAmount = presentTime - lastDidItTime;
    if (elapsedAmount > period){
      pos1 = random (50, 140); 
      pos2 = random (30, 70);
      servo1.attach(9);
      servo2.attach(10);
      servo1.write(pos1);
      servo2.write(pos1);
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      lastDidItTime = presentTime;
      servo3.write(pos2);
    }
  }
  else {
    servo1.write(90);
    servo2.write(90);
    servo3.write(90);
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
  }

}

void autoTune()
{
  if (sensorVal < low)   {     low = sensorVal;   }     if (sensorVal > high)
  {
    high = sensorVal;
  }

  sensorVal = map(sensorVal, low+30, high-30, 0, 255);
  sensorVal = constrain(sensorVal, 0, 255);

}

Assignment 10

An Automaton: Due Wednesday, November 14th

We know how to control actuators (servos and DC motors). Now let’s try to actuate something interesting, in an interesting way.

Working in (optional) two-person teams, make an automaton / kinetic sculpture / mechanical thingy with the following characteristics:

  • It produces a complex and meaningful gesture or movement sequence;
  • It employs at least one laser-cut piece of your own design;
  • It integrates non-laser-cut elements. For example: try non-rigid, non-structural materials (springs, jelly, feathers, balloons, leaves, taxidermy, doll parts, etc.).
  • It has an on-off switch or “GO” button which causes it to enact or start its movement sequence.

Don’t make it interactive or responsive to the environment; focus on the “actuation” and the design of an interesting gesture. The only ‘interactivity’ will be the on/off switch or the “start” pushbutton. Consider, though, some of the other kinds of things you can add to your project: sound from the piezo sound; the cellphone vibrator motor; LED lights…..

For advice on building automatons, please consult this wonderful out-of-print resource (PDF).

You are strongly encouraged to use the Automino kit for assembling the frame of your automaton. On Wednesday 11/7, you will be lasercutting these.

To submit and present your assignment, include the following:

  • An embedded YouTube video (no longer than two minutes) showing video documentation of your project. Show the project executing its motion design, and then give a technical talk-through of its physical design.
  • A text (200 words) describing your project, your design process, and any precursors which may have inspired.
  • Scans of sketches, if possible.
  • An arduino circuit design, rendered using Fritzing.
  • Arduino code, embedded into your blog post using the WP-Syntax plugin.
Comments Off on Assignment 10 Posted in