Assignment
Use force resistive and photocells sensors as input and use variable LEDs
(build on the pulse width modulation exercise from Week 3) as output;
consider multiple force sensors and photocells?
Programming
Create
an interesting visualization on your computer that could be influenced
by the input from the sensors you have (pot, photocell, FSR, or
combination of them). You can use Processing (or any other language you
like) in writing the program. Post your results on the course website.
Mechanical
Create a mechanical construction for
your FSR that distributes or focuses physical force that is applied.
Think about everyday objects (toothpaste tube, entrance mat,
paintbrush, pipette, etc.) and how you measure the pressure or force
applied to them.
Description
Components Used
- 1 red, 1 blue, 1 green led
- 3 220-ohm resistors
- 1 diffuser
- Various lengths of wire
- 1 breadboard
- 1 arduino board
Code
Control LEDs using an FSR:
boolean DEBUG = false;
int sensorPin = 2;
int sensorVal = 0;
int bluePin = 9;
int redPin = 10;
int greenPin = 11;
int pinVal = 0; // Create a global pin value from the sensor val
void setup() {
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(redPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
sensorVal = analogRead(sensorPin);
pinVal = sensorVal / 4;
analogWrite(bluePin, pinVal);
analogWrite(redPin, pinVal);
analogWrite(greenPin, pinVal);
if (DEBUG) {
Serial.println(sensorVal);
Serial.println(pinVal);
}
}