Variable Resistors – WHT

http://youtu.be/Dn_k3N2Y9QE – Circuit 08

http://youtu.be/YWa1vtchHV4 – Circuit 13

Circuit 08

Screen Shot 2014-10-29 at 6.14.29 PM

C08Pic

Circuit 13

Screen Shot 2014-10-29 at 6.13.47 PM

C13Pic

// Will Taylor
// Circuit 8

/* Analog Input

 * Demonstrates analog input by reading an analog sensor on analog 

 * pin 0 and turning on and off a light emitting diode(LED) connected to 

digital pin 13. 

 * The amount of time the LED will be on and off depends on the value obtained by 

 * analogRead().

 * Created by David Cuartielles

 * Modified 16 Jun 2009

 * By Tom Igoe

 * http://arduino.cc/en/Tutorial/AnalogInput

 */

int sensorPin = 0; // select the input pin for the potentiometer

int ledPin = 13; // select the pin for the LED

int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

 pinMode(ledPin, OUTPUT); //declare the ledPin as an OUTPUT:

}

void loop() {

 sensorValue = analogRead(sensorPin);// read the value from the sensor:

 digitalWrite(ledPin, HIGH); // turn the ledPin on

 delay(sensorValue); // stop the program for  milliseconds:

 digitalWrite(ledPin, LOW); // turn the ledPin off: 

 delay(sensorValue); // stop the program for for  milliseconds:

}

// Will Taylor
// Circuit 13

/*
 * Force Sensitive Resistor Test Code
 *
 * The intensity of the LED will vary with the amount of pressure on the sensor
 */

int sensePin = 2;    // the pin the FSR is attached to
int ledPin = 9;      // the pin the LED is attached to (use one capable of PWM)

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  int value = analogRead(sensePin) / 4; //the voltage on the pin divded by 4 (to scale from 10 bits (0-1024) to 8 (0-255)
  analogWrite(ledPin, value);        //sets the LEDs intensity proportional to the pressure on the sensor
  Serial.println(value);              //print the value to the debug window
}

Comments are closed.