Lab #4 Analog input

It’s time for Analog Input lab. Lab partner Erin and I are very excited. We love staying in the studio past midnight to play with our Arduino boards.

Parts we used:
Breadboard, hook up wire, wire stripper, multimeter, Arduino, LEDs, potentiometer, 330 Ohm resistors (or similar), 10K Ohm resistors (or similar), 1K Ohm resistors (or similar), variable resistor (we used the force resistor), glass of water

POTENTIOMETER SETUP

ADD AN LED FOR PWM OUTPUT

LOAD A PROGRAM TO CONTROL THE ARDUINO
We pasted in this code to our Arduino program:

int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
Serial.begin(9600);
}

void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val, DEC);
}

As we adjusted the potentiometer the output numbers changed. This is what we saw on our screen, using the Arduino program:

TRY OTHER VARIABLE RESISTORS
We tried a force sensing resistor like this:

With the multimeter and a 10K resistor – the more pressure we put on the variable resistor, the lower the voltage. The voltage was up to 4.8 volts, and as low as 1 volt. With a 1K resistor, the result was the same.

INVENTION
By the time we had done all this work, we became very thirsty. We could not believe that we had forgotten to drink this whole time. That’s why we invented a device that encourages forgetful drinkers to hydrate more often. We coded Arduino to give different messages depending on how full the water glass is:

  • GLASS FULL: Drink, or you’ll get dehydrated!
  • GLASS HALF FULL: Is your glass half full or half empty?
  • GLASS EMPTY: Thirsty? Fill her up!
  • GLASS LIFTED: Good job, isn’t that water tasty? :D

On the screen, the messages looked like this:

And Erin, our forgetful drinker, just kept filling the glass up, and drinking over and over again in an eternal loop, as we forgot (yeah, we tend to forget a lot of things) to program a message letting her know when enough is enough:

This was our code leaving the forgetful drinker to drink forever and ever:

int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
Serial.begin(300);
}

void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
if (val<=100) { Serial.println("Good job, isn't that water tasty? :D "); } else if ((val>100) && (val<=275)) { Serial.println("Thirsty? Fill her up!"); } else if ((val>275) && (val<=340)) { Serial.println("Is your glass half full or half empty?"); } else if (val>340) {
Serial.println(«Drink, or you’ll get dehydrated!»);
}
}

Next time we’ll turn water into wine.

3 Responses to “Lab #4 Analog input”

  1. What fun!
    I though you where to study more feely arty-farty things, this looks like a playground for geeks, just how we like it (?)! I heard about interactive architecture the other day, it that what you aim for? Or more in a ubiquitous computing/physical computing direction? Weren’t you supposed to study interaction design of sorts?

  2. Kristin sier:

    Well, Physical Computing is one of five classes this fall, so I’m definitely studying other things too. The geeky stuff is taking over the blog because I have to document every lab we do. Don’t know if you noticed my sarcastic tone in these lab documentations? I don’t really understand the electronics part of it, so it’s «galgenhumor»(how would one translate that concept into English?) all over the place. But we’ll be learning programming in Processing now – and I think I will enjoy that a lot more :)

    These are the classes I am taking/will take the 1st year: http://interactiondesign.sva.edu/curriculum/view/first_year/ So many exciting things. Can’t wait to learn more about information visualization and cybernetics/systems design in the spring. Yay!

    So… When are you visiting NYC?

  3. I need to find a good project to do in NYC, if I do, I will come and visit. I’m looking for both a project and a host uni or institution so I can have an exchange semester somewhere. So far I don’t know precisely what and where.

Leave a Reply