Force sensors and Pot

kiera's picture

I worked to figure out the connection between the Arduino and Processing to no avail. I was able to create a force sensor circuit that changed the brightness of LED based on force.

I also revisited the Potentiometer.

I tried to combine the arduino and processing using the code from the tutorial video but the pot was not recognized.

Arduino code

/*
 * Resistive Sensor InputResistive Sensor Input
 * Takes the input from a resistive sensor, e.g., FSR or photocell
 * Dims the LED accordingly, and sends the value (0-255) to the serial port
 */
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
  analogWrite(ledPin, val/4);  // analogWrite (dimming the LED) can be between 0-255
  Serial.println(val/4);       // writing the value to the PC via serial connection
  delay(50);                   // rest a little...
}

Processing code and output
Force Sensor
0
Your rating: None