lab_05 | drinkwatcher
//description
For this lab, I designed a drink coaster that reacts to the amount of weight resting on top of it. When a full glass of beer (for example) is set on top of the coaster, it emits a calm light. As the weight of the glass lessens during the course of drinking the beer, the light gradually increases in intensity. When the beer is empty, the coaster begins to blink.
//supplies
1 x Arduino Uno
1 x Breadboard
1 x 10kohm resistor
1 x Bright white 3 LED strip
1 x FSR
1 x Rockite hyperbolic parabaloid
1 x Silicone rubber base
? x Beers
//code
int sensorPin = 0; // select the input pin for the sensor
int ledPin = 11; // 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<520){
analogWrite(ledPin, 255);
delay(200);
analogWrite(ledPin, 0);
delay(200);
}
else if(val>100) {
analogWrite(ledPin, val); // analogWrite (dimming the LED) can be between 0-255
}
Serial.println(val); // writing the value to the PC via serial connection
delay(50); // rest a little...
}
- Login to post comments
Drupal theme by Kiwi Themes.