Monday, July 16, 2012

Button Activated EL Wire Prototype






Just trying to figure out the options for having my students this year program EL Wire for a dance performance, I wanted to find out if a momentary switch activated EL Wire costume would work. So I worked out a prototype, really just enough to make sure the wiring and programming would be feasible. It was easier than I expected. As a jumping off point I used a fantastic LadyAda Arduino switch tutorial that really explains things well. I still couldn't get the concept of a pull-down or pull-up resistor through my thick head but reading about it again in McRoberts' Beginning Arduino finally made it sink in.
The pics show that individual as well as multiple switch presses work. What my students will do if they want to pursue this idea is sew the switches into gloves and the wires into black outfits for a choreographed dance in the dark.
Here's the code:
UPDATE: The first version is all you need as I learned after making this discovery.
int wirePin[] = {3,4,5};                // create array values corresponding to wire pinOuts
int switchPin[] = {3,4,5};              // same with switch pins

void setup() {
  for(int i = 0;i<3;i++) {
    pinMode(wirePin[i], OUTPUT);    // Set the wire pins as output
    pinMode(switchPin[i], INPUT);    // Set the switch pins as input
  }
}

void loop(){
}
This version is only needed if you use different pins for input and output:
int wirePin[] = {3,4,5};                // create array values corresponding to wire pinOuts
int switchPin[] = {6,7,8};              // same with switch pins
int val[3];                        // variable for reading the pin status

void setup() {
  for(int i = 0;i<3;i++) {
    pinMode(wirePin[i], OUTPUT);    // Set the wire pins as output
    pinMode(switchPin[i], INPUT);    // Set the switch pins as input
    val[i] = 0;                    // Set val array to 0
  }
}

void loop(){
  for(int i = 0;i<3;i++) {
    val[i] = digitalRead(switchPin[i]);   // read input values and store it in val array
    if (val[i] == HIGH) {               // check if any buttons are pressed
      for(int i = 0;i<3;i++) {
        digitalWrite(wirePin[i], HIGH);   // turn wire on in same array index
      }
  }
    if (val[i] == LOW) {              // check if buttons are not pressed
      for(int i = 0;i<3;i++) {
        digitalWrite(wirePin[i], LOW);    // turn wires off
      }
    }
  }
}

Friday, July 13, 2012

Scratch on the Raspi

No new learning today but I added one to yesterday when I brought the Raspberry Pi over to some friends' house for what was supposed to be a dinner invitation but turned into a programming workshop when their two boys, 10 and 14, got it hooked up to their TV. They had never seen Scratch before but the 10 year old, who had already been saying he wants to be a game designer, had that little cat moving all over in response to keystroke in no time despite some resolution issues that made scratch really hard to navigate. For the older boy it sparked an interest in what he could do with text based commands on his MacBook and in no time was compiling Applescripts that did fun stuff with his browser.

EL Wire Beat Detector with Processing on an Arduino

So the hardware here is an Arduino Duemilanove with an EL Escudo sequencer and 3 lengths of 3m ELWire. I'm controlling the Arduino with a Processing sketch because I wanted to use the Sonia audio library to process audio input on the laptop and send pinOut commands to the sequencer. I read a little more on that and it looks like the Minim audio library may be a better choice with more options for isolating pitch frequencies I think. You can see it starts responding to MJ's voice and other sounds. Ultimately I plan to have some students work on programming EL Wire sequences for a student dance performance where the EL Wire will be woven into some costumes. I have to figure out if I can integrate an XBee into the works to send the commands to multiple units over wifi so the costumes can be centrally controlled.
Here's the code:



import processing.serial.*;
import cc.arduino.*;
import pitaru.sonia_v2_9.*;
Arduino arduino;
int[] ledPin = {2,3,4}; // EL Escudo pinOuts start at A=2, B=3, etc.
float beat;


void setup() {
  //println(Arduino.list());
  arduino = new Arduino(this, Arduino.list()[1], 57600);
  for(int i = 0;i<3;i++) {
    arduino.pinMode(ledPin[i], Arduino.OUTPUT);
  }
  
  size(200,200);
  frameRate(30);
  // change beat value or input volume if beat isn't accurate, or maybe your sample does not have a clear enough beat
  beat = 0.03; 
  
  Sonia.start(this);
  // Start listening to the microphone
  LiveInput.start(); 
}


void draw() {
  float level = LiveInput.getLevel();
  if(level > beat) {
     blink();
  }
}


void blink() {
  for(int i = 0;i<ledPin.length;i++) {
    arduino.digitalWrite(ledPin[i], Arduino.HIGH);
  }
  delay(100);
  for(int i = 0;i<ledPin.length;i++) {
    arduino.digitalWrite(ledPin[i], Arduino.LOW);
  }
  delay(100);
}


// Close the sound engine
public void stop() {
  Sonia.stop();
  super.stop();
}

Thursday, July 12, 2012

Configurations, Starting Applications, Current Working Directory

On starting up my Raspberry Pi today I found that my keyboard layout was set back to British, so I will have to find out how to permanently set that. No time right now, though. I did try starting Midori from the command line, which I found, obviously, required the X GUI to be started up. LXTerminal hangs on that command as long as Midori is running so I will have to learn about how to allow it to move on once the target program is running.
What I wanted to learn today I did learn, which is how to know where I am when the GUI is not running. This is not something you really know even with the GUI but the graphical illusion of a desktop gives you the feeling you are somewhere. So on the command line it helps to type 'pwd' to know your current working directory and 'ls' to know what directories and files are in your current location.

Wednesday, July 11, 2012

Changing Keyboard Layout in Linux

Here's my learning for today, although I learned a lot just getting a picture on here and uploading it. (Once I added a USB hub it was a snap.) Open the LXTerminal and type setxkbmap -layout us. The LXTerminal is pretty fancy in that you can even get a right click menu on it (to copy from and to).

Here's my source: http://how-to.linuxcareer.com/linux-command-line-basics-for-beginners-part-3

Raspberry Pi Photos

We'll see if a photo attachment is automatically inserted into a blog post when sent as an email...

Raspberry Pi!

I have a Raspberry Pi! I have a lot to learn as I am barely familiar with Linux at all. But I've decided to learn 1 simple thing a day on it and blog what I learn. My goal for today, for example, is to find out how to change the keyboard mode from UK to EN! I know there is a command for that. (There's an app for that...) Eventually I will set it up in my school's library for students to use it and learn what they can do with it. It is exciting because in this age where computers are ubiquitous black box proprietary devices kids need to also see them as things to tinker with and learn to control in ways they want.

Hmm, how to get a photo I took of the Raspi on here to upload...

Wow, even more challenging than getting a photo on here it seems is getting Midori to handle publishing or saving a post with the blogger platform. It did warn me that there might be problems.

Ok, so I'm emailing it to the blog. I have to use my Outlook Web App account since my gmail account won't work in Midori either. Now, just for the record I don't have a problem with all of these hurdles. To me it's an indication of how sophisticated and at the same time inaccessible the software is that we have come to depend on day-to-day.

Sunday, April 29, 2012

LED Driver project, work in progress

I've been interested in the Arduino for a while now and played with it a little bit. Until now the most involved project I've done with it is playing around with variations on using it to program a web server with an ethernet shield. Well now I'm deep into something that is introducing me to the complexities involved in working a project up as a prototype with breadboards and then taking it to the next level by soldering components together on a generic PCB. I'm using a Philips 4794 LED driver to extend the Arduino's control of LEDs beyond the 8 or so it can control directly with pinouts. Actually I'm using 6 LED drivers to control 43 LEDs that spell out my son's name traced along his toddler version of his written name, bringing his early signature to life in a blinky way. To figure out the components and schematics I relied a lot on this post and this post, and then this post to extend to multiple LED drivers.
So, first the prototype:
 You can see here the Arduino (Duemilanove), breadboards, one LED driver, lots of leads.
And here the LEDs and the circuitry behind.








For programming I used the example in the first link above and changed the value associated with the count variable to include larger numbers of LEDs. I still don't really understand how the program works and ultimately I would like it to do something a little different than it does so I will have to figure that out later. But since that worked for 16 LEDs I started working on a more permanent version. That work in progress is below. There is a lot of soldering to do. By the time I finish, he will be in college:
All 6 LED drivers are soldered in and I tested the circuit to make sure my sloppy soldering
would work with one LED, which I was lucky enough to catch blinking for the camera.

Sloppy soldering...I will blame the cheap soldering iron until
I get a better one and will have no excuse.

Thursday, April 26, 2012

Build Your Own Computer

It's been a long time since I've written anything for no particular reason but being busy. But I recently had 20 high school girls in a class doing something I have to write about. As part of a day full of STEM activities in our high school I had a bunch of girls put together some old PC desktops we were planning to put out to pasture. It was a morning full of anticipation, exploration, frustration, and finally, pure exaltation. I provided scaffolding in the form of a Prezi they could explore  as they needed, gave them screw drivers, and pointed them towards the pile of parts. The best moments were booting up. With some false starts and reseated processors the Dell and Windows splashes started appearing on screens around the room and the girls yelled for joy. They were so excited and proud of their work.

Sunday, December 18, 2011

Do Women Make Technology Differently?

This is a very nice post by Carla Diana. It makes me more determined to bring opportunities to my school for girls to make technology.