Servo Projects

May 2nd, 2011 by Lizabeth Arum No comments »

The students have recently been working on projects with servos. They have been exploring kinetic mechanisms:cams, cranks, linkages and levers. Students were divided into three groups. The first group had to make drawing machines, the second group had to make objects where a door opened something moved in and then out of the doorway and then the door closed, and the last group could make anything as long a servo controlled the movement.

While not all the projects are complete, here are some of them

A flower

Doug the Dancer

A Twitchie

Another Twitchie

More Instruments

May 2nd, 2011 by Lizabeth Arum No comments »

Lots of buttons

Lots of sound

Water Sound

A digital theremin

A button piano

A soft piano

Another soft piano

More soft buttons

Buttons and things

A trumpet

Xbee and the ConnectPort

March 27th, 2011 by Lizabeth Arum No comments »

Inspired by Rob Faludi’s book, Building Wireless Sensor Networks, my students and I have recently been working with Series 1 Xbee radios and the ConnectPort. While the book covers XBee Series 2 (ZB) radios, we just had Series 1 radios laying around, so that’s what we used.

After completing a few exercises that demonstrated how to send data from radio to radio, we plugged the ConnectPort in and controlled a light remotely through a web page. For most of the class, this was the first time writing PHP. This exercise was based on Rob’s example in the book and works just like Make magazine’s Matt Richardson’s Networked On Air Light example, except that our light was a bit smaller—we used a pink 3mm LED.

Once we could control the LED through the form, I challenged the students to control the light both locally and remotely. This turned out to be a bit more complicated than we expected. After several hours of debugging and with some much appreciated help from Rob, it turned out that

  • The connectPort couldn’t handle a url request that returned nothing.
  • We needed to do a little handshaking
  • We needed to be able to resend a request if it failed

The Basic PHP Form

The Second PHP Script

The Arduino Code

The First PHP Script

<html>
<head>
<title>LightingState</title>
<meta http-equiv="refresh" content="5";url="lighting_state_form.php" />
<meta name="viewport" content="width=device-width; initial-scale=1.0;" /> <!-- for iphone size -->
</head>
<body>
<div>
<?php
// define a variable for the data file
$myFile = "lightingState.txt";
// open the data file
$fh = fopen($myFile, 'r') or die("can't open file");

// read the current light setting from the data file

$contents = fread($fh, filesize($myFile));

// close the data file
fclose($fh);
if(!isset($_POST['send'])){
//statements
if ($contents==1){
$contents="On";
}else{
$contents="Off";
}
echo "Light was last: ".$contents;
} else {
$value =$_POST['light'];
if ($value==1){
echo "Light is now: On";
}else{
echo "Light is now: Off";
}
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,$value);
fclose($fh);
}
echo"<form action=".$_SERVER['PHP_SELF']." method='post'>";
echo "<input type='radio' name='light' value='1' /> On<br />";
echo "<input type='radio' name='light' value='0' /> Off<br />";
echo"</label><br />";
echo"<input type='submit' value='Submit' name='send' />";
echo"</form>";
?>
</div>
</body>
</html>

The Second PHP Script

<?php
$value =$_GET['light'];
$myFile = "lightingState.txt";
$fh = fopen($myFile, 'r') or die("can't open file");
$oldValue=fread($fh, filesize($myFile));
fclose($fh);
$fh = fopen($myFile, 'w') or die("can't open file");
if(($value==0 ||$value==1) && ($value!=NULL)){
fwrite($fh,$value);
}else{
fwrite($fh,$oldValue);
}
fclose($fh);
echo "A";
?>

Arduino Code

#include <Tone.h>
#include <Button.h>
/*
* *********ZigBee Internet Gateway Light Example********
* by Rob Faludi http://faludi.com
*/
#define NAME "ZIG Light Example"
#define VERSION "1.00"
#define LED_PIN 13
Button btn=Button(5,PULLDOWN);
int outputLight = 12;
int lightState;
int light;
unsigned long pt;
unsigned long pt2;
boolean lightOn=false;
Tone speaker;
String urlRequest;
boolean received=false;
void setup() {
pinMode(LED_PIN,OUTPUT);
pinMode(outputLight,OUTPUT);
blinkLED(LED_PIN,2,100);
blinkLED(outputLight,2,100);
////////////////////////////////
// faster is better for ZIG, but with Series 1
// this seemed to be the best speed
Serial.begin(57600);
////////////////////////////////
delay(2000);
received=true;
////////////////////////////////
speaker.begin(7);
}
void loop() {
if(btn.uniquePress()){
if(lightOn) {
speaker.play(NOTE_C3,200);
urlRequest="my_url/lighting_state_form2.php?light=0";
speaker.play(NOTE_C3,200);
}else if(!lightOn){
speaker.play(NOTE_C5,200);
urlRequest="my_url/lighting_state_form2.php?light=1";
speaker.play(NOTE_C5,200);
}
received=false;
}
if(!received){
if(millis()-pt2>250){
pt2=millis();
Serial.println(urlRequest);
}
}

if(millis()-pt>1000){
pt=millis();
if(received){
Serial.println("my_url/lightingState.txt");
}
}
////////////////////////////////
// if there's a byte waiting
if (Serial.available() > 0) {
////////////////////////////////
// read the ASCII numeral byte
lightState = Serial.read();
////////////////////////////////
//do a little handshaking
if(lightState=='A'){
//run a timer if false, if it waits too long resend it
received=true;
digitalWrite(13,HIGH);
delay(250);
}else{
digitalWrite(13,LOW);
}
////////////////////////////////
if (lightState == '0' || lightState=='1') {
lightState=lightState-48;
if(lightState==1){
lightOn=true;
light=1;
} else if(lightState==0){
lightOn=false;
light=0;
}
}
}
digitalWrite(outputLight, light);
}

////////////////// UTILITIES //////////////////
// this function blinks the an LED light as many times as requested, at the requested blinking rate
void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
for (int i=0; i<numBlinks; i++) {
digitalWrite(targetPin, HIGH); // sets the LED on
delay(blinkRate); // waits for blinkRate milliseconds
digitalWrite(targetPin, LOW); // sets the LED off
delay(blinkRate);
}
}

This is really Something.

March 15th, 2011 by Lizabeth Arum No comments »

A friend of mine found something in Austin

Twitter Lamp

March 9th, 2011 by Lizabeth Arum No comments »

Twitter Lamp from SACC-PC on Vimeo.

This assignment began as a challenge to use Physical Computing to solve a problem at school. The initial problem the students selected dealt with entering the school in the morning. Rather than typing a password or swiping a card, the students decided that those entering the building should be able to walk by a reader that records their id from a tag on their bag.

From the initial proposal, the students decided to use the RFID reader in a more interactive way. At the same time, the students were introduced to ThingM’s BlinkM, a smart RGB LED.

The project that evolved associated ID tags with colors and allowed a person to mix the primary colors by using two to three cards sequentially. The RGB LED reflected the colors chosen. In addition to creating a RFID controlled lamp, a randomly generated color poem matching the selected color would be tweeted. This way one person could enjoy the lamp locally while others could enjoy the selection remotely.

See the details

The students also created an Instructable

Instruments

March 9th, 2011 by Lizabeth Arum No comments »

Here’s a sample of recent student work using Arduino and the Tone Library

 

Some Soft Circuit Projects

March 8th, 2011 by Lizabeth Arum No comments »

Button Fun

November 3rd, 2009 by Lizabeth Arum No comments »

This was my example. When you clicked the button, the face appeared and a sound file of a scream played.
I also suggested, to help students understand the interaction, that they could start with a picture of an animal, like a pig. If you clicked the tail, the image should change and a squeal should play.
surprise

iPhone Project with buttons and sound

  1. Create a background image

  2. Create a foreground image

  3. Create an icon image 57 x 57px

  4. Find a sound. Open the sound in Audacity and save as 32-bit sound.

  5. Open XCode

  6. Create a ViewBased Project

  7. Add the images and the sound

  8. Update the plist file

  9. Add a framework by CTRL+clicking on Frameworks. Select Existing Frameworks and add AudioToolbox.framework
    add_framework

  10. Open the header file

  11. Create a statement that imports the AudioToolbox/AudioToolbox.h

  12. Add 3 IBOutlets. One to hold a UILabel and the other two to hold pointers of type UIImageView

  13. Create a pointer of type NSTimer and name it resetTimer

  14. Create a a variable named sound of type SystemSoundID

  15. Create 3 @property declarations for the label and the UIImageViews

  16. Create a buttonPressed IBAction that takes sender of type id as its parameter.

  17. Open the implementation file

  18. @synthesize the properties

  19. Define the buttonPressed method:
    1. Set the text of your label to your message

    2. Create a pointer named foregroundImg of type UIImage and set it to the UIImage method imageNamed with the name of your foreground image as your parameter

    3. Set the image of the UIImageView that will pop up, to be the variable you just created (foregroundImg)

    4. Set the hidden property of that UIImageView to NO

    5. Test if sound and

      if the condition is met, then call:
      AudioServicesPlaySystemSound(sound);

    6. Test if resetTimer does NOT equal nil

      If the condition is met, then call:
      [resetTimer invalidate];

    7. Now set resetTimer to
      resetTimer = [NSTimer scheduledTimerWithTimeInterval:1.1 target:self selector:@selector(resetImages:) userInfo:nil repeats:NO];

  20. Now you have to define the method you just called (resetImages)


    - (void)resetImages:(NSTimer *)sender{

    }

  21. Inside the method:
    1. Set the hidden property of the UIImageView that pops up to YES

    2. Empty the label.

    3. Set resetTimer to nil

  22. Navigate to and uncomment viewDidLoad

  23. After the call to super, include these lines (remember to update the name of your audio file):

    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundUrlRef = CFBundleCopyResourceURL(mainBundle, CFSTR ("aaaah2"), CFSTR ("wav"), NULL);

    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (soundUrlRef, &sound);

  24. Open the nib file and add a UIImageView

  25. Using the inspector set it to hold your background image
  26. Add a label

  27. Add a button
    bgImage

  28. Add another UIImageView and align it with the bottom
    bottom

  29. Connect The File Owner to label and select label
    to_label

  30. Connect the button to the File Owner and select buttonPressed
    btn

  31. Connect the File Owner to the UIImageView aligned to the bottom and select the name holding the UIImageView that pops up
    imageView

This project was inspired by Rory Lewis’s tutorials

Some early projects

November 2nd, 2009 by Lizabeth Arum No comments »

Physical Computing

Here are a few of the recently completed projects:P1120064
FSR and LEDs

MovieA soft circuit button and LEDs

light4
Potentiometer controlled LEDs with 2 modes controlled by a button

img3
FSR controlled spooky eyes

A few other interesting projects are in the works. Two involve the capacitive sensor. The first uses a hacked disposable digital camera that flashes when the sensor is triggered. The second project was created as a Halloween installation. I hope there were pictures!

A Short Week

October 16th, 2009 by Lizabeth Arum No comments »

I finished my soft circuit. Now when you pet it it purrs and flashes its eyes. I added a homemade capacitance sensor and a vibrating motor. I started with this information, but ended up using Paul Badger’s CapacitiveSense003 library which worked great. My circuit uses a 2.2MΩ resistor to connect pins 2 and 5 and the sensor itself is made of conductive frabric from LessEMF. The piece came from the Fabric Sample Set (Cat. #SAMPLER) and I cut in in half and connected it to pin 2 through conductive thread and a 22 AWG hookup wire.

Here’s the code:

#include
const int purr = 9; // pin that the LED is attached to
const int led = 3; // pin that the LED is attached to
const int eye1=10;
const int eye2=11;
const int mouth=4;
boolean purring=false;
boolean openEyes=false;
CapSense cs_1_2 = CapSense(1,2);

void setup(){
pinMode(purr, OUTPUT);
pinMode(led, OUTPUT);
pinMode(eye1, OUTPUT);
pinMode(eye2, OUTPUT);
pinMode(mouth, INPUT);
pinMode(led,OUTPUT);

pinMode(purr,OUTPUT);
digitalWrite(purr, LOW);
Serial.begin(9600);
}

int touch_sensor(){
long start = millis();
long total1 = cs_1_2.capSense(30);
if (total1<02){
return 1;
}else{
return 0;
}

/*Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing

Serial.print(total1); // print sensor output 1
// print sensor output 3

delay(10); */
}

void loop(){
int touch=touch_sensor();
if (digitalRead(mouth)){
openEyes=true;
}
else{
openEyes=false;
}

if(!touch){
if(purring){
for(int i=255;i> 0;i-=10){
analogWrite(purr,i);
delay(20);
}

purring=false;
}
else{
analogWrite(purr,0);
openEyes=false;
}
digitalWrite(led,LOW);

}
else{
purring=true;
digitalWrite(led,HIGH);

analogWrite(purr,200);
openEyes=true;

}
if (openEyes){
for(int i=65;i<255;i+=10){
analogWrite(eye1,i);
analogWrite(eye2,i);
delay(10);
}
for(int i=255;i>65;i-=10){
analogWrite(eye1,i);
analogWrite(eye2,i);
delay(10);
}}else{
analogWrite(eye1,0);
analogWrite(eye2,0);
}
}


Students worked on their own soft circuits this week with different enthusiasm levels. Students used to working through labs, but not producing pieces, enjoyed this assignment far less than those who like to make crafts. Still, I believe introducing students to conductive thread and conductive fabrics will help them construct later projects.

We did run into a few glitches this week as well. One student plugged 12V into the freeduino. The 12V plug was used in our first experiments, and I had mentioned that the freeduino could be powered by the USB or a battery. I had extra Atmega chips and, apart from the chip, the board seemed fine.

Another student had trouble finding the usbserial port. At first I thought that the FTDI Drivers for Intel Macs was not installed, but then he moved to another computer with the same problem. His circuit seemed fine. In the end, it turned out that the USB cable was to blame. As soon as we switched cables, everything worked. It was a brand new cable and it surprised both of us that this was the source of the problems.

IPhone programming is going a bit slower than I anticipated. The class was still working on the second version of the Browser assignment this week. In the meantime, I came up with a way for students to create web pages to document their work:


Background-color:

Application name:


Notes:


File Name:


Code:

 

The Blender class is going well. Students have started working with armatures and materials. They have made short quicktime movies of the experiments and everyone is still engaged in the process.