Description
For this assignment I created a plastic cup that would light if if it was half full or greater, based on the output of an FSR. It was constructed of two plastic cups, the outer one with holes in it for the FSR wires and the LED, and the inner one with a phillips machine screw taped to the bottom of it to activate the FSR. The inner cup was placed within the outer cup, and then the inner cup was filled over halfway with water. Unfortunately, the inner cup experienced some structural integrity problems and the FSR was lost, although the LED continued to work while accidentally submerged.
Parts Used
- 1 ea Arduino board
- 1 ea Breadboard
- 1 ea 220 ohm resistor
- 1 ea 10K ohm resistor
- 1 ea FSR (RIP)
- 2 ea plastic cups
- 1 ea Phillips machine screw
- 6 oz water
Arduino Code
/*
*
* If the cup is half full or more, the LED lights
*
*/
int sensorPin = 0; // select the input pin for the sensor
int ledPin = 13; // select the output pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(sensorPin); // read the value from the sensor, 0-1023
if(val>= 500) {
analogWrite(ledPin, 255); // analogWrite (dimming the LED) can be between 0-255
} else {
analogWrite(ledPin,0);
}
Serial.println(val); // writing the value to the PC via serial connection
delay(50); // rest a little...
}
Images
Comments
red is such a manic color if
red is such a manic color if you're to see the cup as half full. how about the more calming blue? :) Nice work!