This is the first Switch Circuit, when you close the circuit, the LED blinks…

Arduino LED Switch from chouza on Vimeo.

And now for the second one, when you press the fuzzy black square, the light slowly turns on and becomes brighter.

Pressure Arduino Circuit from chouza on Vimeo.

This slideshow requires JavaScript.

And here is the code for the pressure sensor:

/*
Analog Input- Pressure sensor to turn on LED.
Created by David Cuartielles
Modified 16 Jun 2009 By Tom Igoe
Modified 5 March 2011 By Ximena Chouza
*/

int sensorPin = 0;    // select the input pin for the potentiometerint
ledPin = 11;     // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}

void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
analogWrite(ledPin, sensorValue);
}

Advertisements