Potentiometers!

What is a potentiometer (or pot)? Simply put, it's an electric knob. Sometimes it will be called a variable resistor, which is also an accurate description of what it does - it variably resists the voltage.
It's actually easier to wire a pot than a button. The middle pole goes to an analog input pin. The other two poles are interchangeable - one goes to the 5v pin the other to ground. here's a picture of how to wire it. Of course you either want to solder those joints, or use alligator clips, but you get the idea.


What we get from this is a value somewhere between 0 and 1023. Here's some code.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int analogPin = 0;

void setup()
{
arduino = new Arduino(this, Arduino.list()[0]);
}

void draw()
{
println (arduino.analogRead(analogPin));
}


so what? here we combine the LED and the pot for a controllable blinkie. Make sure you put an led in pin 13 to see the results.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int analogPin = 0;
int ledPin = 13;
int blinkspeed = 0;
int counter = 0;
boolean blink = false;

void setup()
{
arduino = new Arduino(this, Arduino.list()[0]);
}

void draw()
{
counter ++;
blinkspeed = arduino.analogRead(analogPin);
if (counter > blinkspeed) {
counter = 0;
if (blink == false){
arduino.digitalWrite(ledPin, Arduino.HIGH); // light goes on
blink = true;
}
else{
arduino.digitalWrite(ledPin, Arduino.LOW); // light goes on
blink = false;
}
}


okay, now try using a photocell! Here's the wiring diagram. You can do it!

If you use analog pin 0 you can use the same code as above.