RGB Pencil

 

This project uses the resistance in a graphite pencil to change the colors of an RGB LED. I built the two parts separately to make sure they worked before combining them.

 

I used the directions and some example code, included at the bottom of the page, to make the RGB LED work. Getting this up and running was pretty easy.

Hooking up the pencil was fun, I created a simple circuit and tested it by writing to serial.

Then I put the two together to get this:

int pencilResistance;


int RED_PIN = 9; //set pins for LEDs
int GREEN_PIN = 10;
int BLUE_PIN = 11;


void setup() {
  Serial.begin(9600); //typical speed for communication
  pinMode(0, INPUT); 
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);

}


void loop() {
  pencilResistance = analogRead(0);
  //Serial.println(pencilResistance);

  int pencilRGB = map(pencilResistance, 0, 1023, 0, 767);
  Serial.println(pencilRGB);
  
  showRGB(pencilRGB);

  
}



void showRGB(int color)
{
  int redIntensity;
  int greenIntensity;
  int blueIntensity;

  if (color <= 255)          // zone 1
  {
    redIntensity = 255 - color;    // red goes from on to off
    greenIntensity = color;        // green goes from off to on
    blueIntensity = 0;             // blue is always off
  }
  else if (color <= 511) // zone 2 { redIntensity = 0; // red is always off greenIntensity = 255 - (color - 256); // green on to off blueIntensity = (color - 256); // blue off to on } else // color >= 512       // zone 3
  {
    redIntensity = (color - 512);         // red off to on
    greenIntensity = 0;                   // green is always off
    blueIntensity = 255 - (color - 512);  // blue on to off
  }

  // Now that the brightness values have been set, command the LED
  // to those values

  analogWrite(RED_PIN, redIntensity);
  analogWrite(BLUE_PIN, blueIntensity);
  analogWrite(GREEN_PIN, greenIntensity);
}

That’s it!

There’s quite a bit more to the example code Sparkfun provided, but I didn’t need all of it:

const int RED_PIN = 9; //set pins for LEDs
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;

int DISPLAY_TIME = 100;  // In milliseconds for the set colors

void setup()
{
  // Here we'll configure the Arduino pins we're using to
  // drive the LED to be outputs:
  Serial.begin(9600); //typical speed for communication
  pinMode(0, INPUT); 
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
}


void loop()
{

  mainColors();
  

  showSpectrum();
}


// Here's the mainColors() function we've written.

// This function displays the eight "main" colors that the RGB LED
// can produce. If you'd like to use one of these colors in your 
// own sketch, you cancopy and paste that section into your code.

void mainColors()
{
  // Off (all LEDs off):

  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);

  delay(1000);

  // Red (turn just the red LED on):

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);

  delay(1000);

  // Green (turn just the green LED on):

  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, LOW);

  delay(1000);

  // Blue (turn just the blue LED on):

  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, HIGH);

  delay(1000);

  // Yellow (turn red and green on):

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, LOW);

  delay(1000);

  // Cyan (turn green and blue on):

  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, HIGH);

  delay(1000);

  // Purple (turn red and blue on):

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, HIGH);

  delay(1000);

  // White (turn all the LEDs on):

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, HIGH);

  delay(1000);
}


// Below are two more functions we've written,
// showSpectrum() and showRGB().

// showRGB() displays a single color on the RGB LED.
// You call showRGB() with the number of a color you want
// to display.

// showSpectrum() steps through all the colors of the RGB LED,
// displaying a rainbow. showSpectrum() actually calls showRGB()
// over and over to do this.

// We'll often break tasks down into individual functions like
// this, which makes your sketches easier to follow, and once
// you have a handy function, you can reuse it in your other
// programs.


// showSpectrum()

// This function steps through all the colors of the RGB LED.
// It does this by stepping a variable from 0 to 768 (the total
// number of colors), and repeatedly calling showRGB() to display
// the individual colors.

// In this function, we're using a "for() loop" to step a variable
// from one value to another, and perform a set of instructions
// for each step. For() loops are a very handy way to get numbers
// to count up or down.

// Every for() loop has three statements separated by semicolons:

//   1. Something to do before starting

//   2. A test to perform; as long as it's true,
//      it will keep looping

//   3. Something to do after each loop (usually
//      increase a variable)

// For the for() loop below, these are the three statements:

//   1. x = 0;     Before starting, make x = 0.

//   2. x < 768;   While x is less than 768, run the
//                 following code.

//   3. x++        Putting "++" after a variable means
//                 "add one to it". (You can also use "x = x + 1")

// Every time you go through the loop, the statements following
// the loop (those within the brackets) will run.

// And when the test in statement 2 is finally false, the sketch
// will continue.


void showSpectrum()
{
  int x;  // define an integer variable called "x"
  
  // Now we'll use a for() loop to make x count from 0 to 767
  // (Note that there's no semicolon after this line!
  // That's because the for() loop will repeat the next
  // "statement", which in this case is everything within
  // the following brackets {} )

  for (x = 0; x < 768; x++)

  // Each time we loop (with a new value of x), do the following:

  {
    showRGB(x);  // Call RGBspectrum() with our new x
    delay(10);   // Delay for 10 ms (1/100th of a second)
  }
}


// showRGB()

// This function translates a number between 0 and 767 into a
// specific color on the RGB LED. If you have this number count
// through the whole range (0 to 767), the LED will smoothly
// change color through the entire spectrum.

// The "base" numbers are:
// 0   = pure red
// 255 = pure green
// 511 = pure blue
// 767 = pure red (again)

// Numbers between the above colors will create blends. For
// example, 640 is midway between 512 (pure blue) and 767
// (pure red). It will give you a 50/50 mix of blue and red,
// resulting in purple.

// If you count up from 0 to 767 and pass that number to this
// function, the LED will smoothly fade between all the colors.
// (Because it starts and ends on pure red, you can start over
// at 0 without any break in the spectrum).


void showRGB(int color)
{
  int redIntensity;
  int greenIntensity;
  int blueIntensity;

  // Here we'll use an "if / else" statement to determine which
  // of the three (R,G,B) zones x falls into. Each of these zones
  // spans 255 because analogWrite() wants a number from 0 to 255.

  // In each of these zones, we'll calculate the brightness
  // for each of the red, green, and blue LEDs within the RGB LED.

  if (color <= 255)          // zone 1
  {
    redIntensity = 255 - color;    // red goes from on to off
    greenIntensity = color;        // green goes from off to on
    blueIntensity = 0;             // blue is always off
  }
  else if (color <= 511) // zone 2 { redIntensity = 0; // red is always off greenIntensity = 255 - (color - 256); // green on to off blueIntensity = (color - 256); // blue off to on } else // color >= 512       // zone 3
  {
    redIntensity = (color - 512);         // red off to on
    greenIntensity = 0;                   // green is always off
    blueIntensity = 255 - (color - 512);  // blue on to off
  }

  // Now that the brightness values have been set, command the LED
  // to those values

  analogWrite(RED_PIN, redIntensity);
  analogWrite(BLUE_PIN, blueIntensity);
  analogWrite(GREEN_PIN, greenIntensity);
}

Your Eyes Light Up: P Comp Switch Project

I decided to make a stuffed animal whose eyes lit up for this project. The switch would be in the animal’s hands. When you hold them together, the circuit would be complete.

IMG_3043

I started with a plush souvenir bear, then opened up the seam on its back and removed the stuffing and eyes. The eyes were tricky to get out and I ended up having to use a dremel to cut the fasteners inside the bear’s head.

IMG_3044

After I had enough of the stuffing out I sewed patches of conductive thread on the bear’s hands. I planned on threading the wire under the patches inside the bear. This proved hard to do later, and I should have sewn the wire in while I was sewing the patches in.

I planned on using a 9V battery to power the bear, since I already had one in my toolbox. This meant doing a little light math to see what kind of resistor I needed to use.

IMG_3047

You can also see my basic circuit diagram and how I sketched out what the wiring would be inside the bear.

IMG_3046

Next I built the circuit on a breadboard, to make sure everything worked the way it should. You can’t tell from the picture, but there is a 200 ohm resistor in there along with the LEDs.

Next I wired up the inside of the bear. I didn’t end up soldering the wires in place, because this version of the project it pretty  basic. I wanted to leave myself the option of cutting everything out again without ruining too much work. Instead I used ‘jeweler’s loops’ to secure the wires and then crimped the ends together. I don’t have a picture of this step because I was so happy to get everything together that I forgot to stop and snap one.

As soon as I got all the wiring done I took a quick video of the eyes lighting up. Then I stuffed the bear back up. I safety pinned the back of the bear, so I can take him apart again later if I want to.

It might be nice to get some LED holders for the eyes so they don’t stick out strangely like they do now. He could also use a nice zipper on his back instead of the pins.

On Interaction

Why interactivity?

Interactivity is high quality dynamic communication. Crawford describes this as a listening, thinking, speaking cycle with at least two actors and I like his definition. I especially like how this clearly sets interactions apart from reactions and participation, without diminishing reactions or participation. Each experience has its own value, but interactivity allows you to project yourself on the world which makes it the most satisfying.

Why physical interactivity?

Most of our interactions are physical interactions. We exist in the world as full corporeal beings and are cheating ourselves if we only use part of what we are. Physical interaction allows for the communication of more meaning, using more senses. There is a lot more out there than colored blobs on a screen even if we add words, pictures, and video into the mix. We don’t need to communicate the way computers do, they need to work more like people. This has been the trend from the very beginning, away from command line interactions closer and closer to how human bodies work.  

What makes for good physical interaction?

A good physical interaction engages the senses. It provokes an emotional response. Ideally for a tool interaction it should produce delight and satisfaction, for art there are a lot more options. You shouldn’t have to know how to do anything to have the interaction, as the designer should be using humans, or other animal, as the starting point and building on our existing forms and mental predilections. It should lead the participant to the point of discovery with little to no trouble.

Are there works from others that you would say are good examples of digital technology that are not interactive?

The work of artist, and ITP alum, Leo Villareal comes to mind. His work is, as far as I know, not interactive work. However, they are still captivating installations. This work allows for wonderful reflection. Instead of interacting the viewer is given the opportunity for introspection, which can also be a high quality emotional experience.

I was particularly struck by his installation in the National Gallery Concourse: 

Leo Villareal- Multiverse Go Pro from Gustavo Bernal on Vimeo.