Types:
Force Sensing Resistors:
Reading Variable Resistances with the Arduino:
int ledPin = 13; // LED pin int analogPin = 3; // potentiometer pin int val = 0; // variable to store the value read int threshold = 512; // threshold void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output } void loop() { val = analogRead(analogPin); // read the input pin if (val >= threshold) { digitalWrite(ledPin, HIGH); // sets the LED on } else { digitalWrite(ledPin, LOW); // sets the LED off } } |
![]() | ©2004-2020 McGill University. All Rights Reserved. Maintained by Gary P. Scavone. |