Week 5: The Worst Camera in the World

For my latest pcomp project, I decided to try to make The Worst Camera in the World. Initially, I wanted to create a grid of photoresistors, that would act as really, really, bad photosensitive plate that (hopefully) would capture at least a black-and-white impression of whatever was before it. I quickly realized that I did not have 25 photoresistors hanging around, and the shop didn't carry them for free. The shop DOES, however, offer quite a few LEDs for free, and I decided to act on a rumor I once heard: if you reverse the polarity of an LED, it will act as a photo resistor.

Dear reader, the rumors are true.

Amitabh, one of the second years, pointed out that an Arduino won't be able to handle 25 analog inputs, and suggested that I attach a row of LEDs to a servo motor that then moves through set intervals.

What a beautiful idea! And, basically, a very similar concept to my light wand from last week!

So far, I've only built it out with one LED to ensure that the basic concept works. The code is below:

#include <Servo.h>

int photo1 = A0; 
int photo2 = A1;
int photo3 = A2; 
int photo4 = A3;
int photo5 = A4; 

int maxVal = 0; 
int minVal = 1023;
float avgVal = 0;

Servo myservo;
int pos = 0;

int mappedValue;

void setup()
{
    Serial.begin(9600);  //Begin serial communcation
    
    pinMode(photo1, INPUT);
    myservo.attach(9);
    myservo.write(0);
    
}

void readPixel(int photoPixel){

  int potVal = analogRead(photoPixel);
  avgVal = avgVal * 0.95 + potVal * 0.05;
  
  if (potVal > maxVal) maxVal = potVal;
  if (potVal < minVal) minVal = potVal;

//  int mappedValue = map(potVal, 800, 1023, 0, 255);
  mappedValue = map(potVal, minVal+50, maxVal, 0, 255);
  
  }

void displayPixel(){

    if (mappedValue > 200) {   
      Serial.print("▢");
    } else if ((mappedValue < 200) && (mappedValue > 60)) { 
      Serial.print("▨"); 
    } else {
      Serial.print("▩");
    }
  }
  
void resetServo(){
  pos = 0;
  myservo.write(pos);
}

void updateServo(){

  pos = pos+(180/5);
  myservo.write(pos); 
  
  readPixel(photo1);
  displayPixel();

  readPixel(photo1);
  displayPixel();

  readPixel(photo1);
  displayPixel();

  readPixel(photo1);
  displayPixel();

  readPixel(photo1);
  displayPixel();

  if (pos >= 180) resetServo();
  delay(2000/5);
  
}

void loop()
{

  // if switch is pushed, "take a picture"
    updateServo();
    Serial.println(" ");
  
}

Here’s what my (currently) one-pixel camera displays:

And here’s a sketch of where I’m hoping to take it:

I need to build out the complete attachment for the servo, with 4 other LEDs, and I hope to have a picture of 5x5 resolution… that can capture when a blob is before it.

Amitabh also noted that it maybe helpful to have a pinhole lens or some other contraption for better controlling the light into my photosensitive grid…

For now, it remains work in progress!

#pcomp 


Week 4: Light Wand

I was really inspired by Light Art Club last week (Fridays at noon! Everyone should come!), and I wanted to continue working with the LED strip I had been playing with. To connect to some of what we were learning in PComp, I decided I would add dials my LED setup to control their RGB values. In the ideation phase, I thought it would be fun to also add switches to change between a few lighting patterns (but that idea never quite made it to the prototype I built).

I soldered a few potentiometers to use as dials (helping hands are amazing??).


And I plan to use these forever.


It was pretty easy to adjust the code we used in class to the specifications of what the NeoPixel library functions required to change the LED colors (basically, I mapped the raw values off the potentiometers to values between 0 and 255).

I really enjoyed playing with the dials! Turns out, it's way more fun to adjust the value of a variable using a dial, rather than going in and editing your code. And, I liked the level of immediate control I had over the exact color I was seeing.


At this point, I wanted to attach my LED strip to a motor that would spin my strip back and forth. It took me quite a while to figure out how to write the code so that the LED lights and the motor weren't holding each other up, timing-wise. It's not completely perfect, but here's what I came up with:

#include <Servo.h>
#include <Adafruit_NeoPixel.h>

#define LEDPin 6 
#define N_LEDS 10 
#define controlRed A0
#define controlGreen A1
#define controlBlue A2

Servo myservo;  
int pos = 0;
int lastPos = 1; 
bool reverse = false;

int oldRed = 5000; 
int oldGreen = 5000;
int oldBlue = 5000; 

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, LEDPin);  

void setup() {
  myservo.attach(9);

  pinMode(controlRed, INPUT); 
  pinMode(controlGreen, INPUT);
  pinMode(controlBlue, INPUT); 
  
  strip.begin();
  strip.show();

  Serial.begin(9600);
}

void updateLights() {

    int redPin = analogRead(controlRed);
    int redMapped = map(redPin, 1000, -10, 5, 255);

    int greenPin = analogRead(controlGreen);
    int greenMapped = map(greenPin, 1000, -10, 5, 255);

    int bluePin = analogRead(controlBlue);
    int blueMapped = map(bluePin, 1000, -10, 5, 255);
    
    if (blueMapped != oldBlue || greenMapped != oldGreen || redMapped != oldRed){
      
        for (int i=0; i<N_LEDS; i++) {

            strip.setPixelColor(i, redMapped, greenMapped, blueMapped);
            strip.show();
            
            oldBlue = blueMapped; 
            oldRed = redMapped;
            oldGreen = greenMapped; 

            strip.show();
        }
    }

}

void updateServo(){

  if (reverse) {
    
    lastPos = pos; 
    myservo.write(pos);
    pos -= 10;
    delay(5); 
    
  } else {

    lastPos = pos;     
    myservo.write(pos);
    pos += 10;
    delay(5); 
                  
  }
}

void loop() {

  updateLights();

  if (pos != lastPos) {
      updateServo();    
  }

  if (pos == 180) reverse = true; 
  if (pos == 0) reverse = false;
  
}

It looks like this IRL:

A bit violently wiggly, without the servo being more locked down. Makes me laugh though.

I initially, I had been using Arduino's Sweep code, but it relied too heavily on for-loops to suit my purposes (so slow). This code made the motor move as smoothly as I wanted, and the dial remained responsive (though I thought I saw a bit of flickering in the LEDs).

Though I spent a lot of time fixing the motor + responsive dial setup, I was a bit disappointed in how the "light wand" performed with the servo motor moving the LED trip from 0 to 180 and back. I tried to take a few long exposure photos on my phone, which were only fast enough to capture the following:


When I snuck into the micro studio with a proper DSLR, I discovered that even in the most ideal conditions, the "rendered" light painting looked rather like an wifi symbol. I think this could be improved if I had implemented my pattern switches, and perhaps took more time to play around with timing, but for then, the result was somewhat disappointing. Maybe I do want my code to play around with colors, so that I can free up my hands for movement.

I took a bunch of long exposure photos of just the light wand, no motor, seen below. I tried to adjust the colors on my dials while waving around the wand, to varying degrees of success.







#pcomp 


Week 3: Observation

This weekend, I went to Maker Faire (for the first time!), and I had the chance to watch both adults and children play with several interactive technologies, but I was especially interested in their interactions with artful pieces. One such piece was a fellow ITP student's project called Presence. The project consisted of a series of tubes that reacted to the presence (and pose) of the people that came before it. The tubes were each marked with black diagonals that allowed participants to have a clear sense of the tubes' rotation in reaction to their own movements.

It was really interesting to watch people of all ages interact with the piece. Kids, unsurprisingly, approached it with the most enthusiasm (dancing or just shaking their entire torsos). Adults tended to make more intentional movements with their arms (though a few of them danced). The primary interaction point was the series of rotating tubes, but just off to the side, a computer screen showed how PoseNet had mapped the physicality and movement of the people in front of the piece. Some people actively watched both the sculpture and the monitor, as though hoping to map their own movememnts to what was happening in each. Others seemed to ignore it entirely. Though the piece allowed for plenty of "feedback" and it seemed easy enough to make the sculpture do something, it looked harder to interpret its actions. Though our readings in The Design of Everyday Things have some stringent ideas about the clarity of purpose necessary in "good" design, I think the requirements of an interactive art piece are different than other types of interactive objects. I thought this design was especially successful in nudging participants into a more playful mode of being, and with its minimal aesthetic, perhaps encouraging participants to approach with a certain openness to an experience made as much by their own participation as the piece itself.


Update: Added a link to the project and a photo.

#pcomp 


This is Me Now

I have found the perfect way of emphasizing the gaps in my resume.

#personal 


Week 3: Digital Input + Digital Output

The project I ended up with this week was quite different than the project I had started with. Initially, after hearing the prompt last week, I had briefly considered trying to build a tic-tac-toe board. This, upon closer inspection of what it would entail, seemed like Too Much.

Instead, I implemented a switch that changed the speed of an LED when pressed, resulting in an increasingly erratic LED that finally settles on being on all the time. Maybe a metaphor for anxiety, but regardless, Too Simple.

*Finally,* I settled on a slightly more complicated iteration of the last idea: a contraption for blowing out LED birthday candles (inspired by a fan I found on the junk shelf).


First, I made sure my idea worked reasonably well, by setting up a row of LED lights on a breadboard to “blow out.” I had to finagle a bit with the Arduino code – I didn’t want the candles to blow out right away. It wanted it to feel as though a slightly asthmatic loved one was doing their best to knock out the lights and make a wish. The basic interaction was that the user would push a switch to turn on the fan, which, after a period, would blow out the candle. I played with the code a bit to make the switch unresponsive for a period of time after a button press to simulate someone sort of huffing/struggling to blow out the candles. After a certain number of presses, the candles would begin to flicker and later, give out altogether.

Once everything was working, I sent out to construct the birthday candles (straws courtesty of Sweetgreen!). I soldered some additional wire onto my LEDs so that they could travel length of the straws (which were shortened for my purposes.) I tested each LED within my circuit to ensure that they were still working after my clumsy soldering, and then covered the straws with blue painter’s tape.



To make the “cake,” I cut out a circle out of cardboard and made 5 small triangles at each spot I wanted a candle. Much easier than attempting to cut a tiny circle with an exacto knife.


I then attempt to create the LED portion of the circuit off of the breadboard, with mixed success. Mixed in the sense that it worked, but it was a MESS.


I have a lot to learn about properly managing wires / the organization of my circuit once I move off the breadboard. I found myself thinking, “There has to be a better way of doing this” quite often.

Here’s the whole contraption in action (the setting is intentionally a bit dark to help those LED candles pop):

#pcomp