If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.
You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!
int sensorPin = A0; // 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() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
if(sensorValue > 255){
sensorValue = 255;
} else if(sensorValue < 0){
sensorValue = 0;
}
analogWrite(ledPin, sensorValue);
}
Correct, but It needs to be divided by 4 also because the analog input resolution is 10 bits, and the PWM output is 8 bits. The program will work without that division, although the LED will change value from high to low 4 times over a full potentiometer rotation.
2. Flex Sensor
a. What resistance do you see with a Multimeter when the sensor is flat? When it is bent?
10k -> 50k
straight -> bent
✔
b. What kind of voltages should we expect for the Arduino analog pin based on the sensor resistance?
(R2/(R1+R2)) * V(in) = V(out)
✔great response
straight:
(27000/(10000+27000)) * 3.3 = (27/37) * 3.3 = 2.4 V
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPin = A0; // 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);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
sensorValue = analogRead(sensorPin);
lcd.clear();
lcd.print(sensorValue);
analogWrite(ledPin, sensorValue);
delay(1000);
}
✔
3. Force Sensitive Resistor
a. What resistance values do you see from your force sensor?
0-1000 Ohms
Resistance should be very high (infinite or M Ohms) when the FSR is not pressed. Resistance should lower to a few hundred Ohms, or low K Ohms, when pressed hard. -0.25
b. What kind of relationship does the resistance have as a function of force applied? (e.g., linear?)
It follows a power law until the force saturation (maximum detectable force). (datasheet)
✔
c. Include a copy of your FSR thumb wrestling code in your lab write-up.
/*
LiquidCrystal Library - display() and noDisplay()
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD and uses the
display() and noDisplay() functions to turn on and off
Comments (1)
zahraa@... said
at 9:24 pm on Aug 4, 2015
good job
You don't have permission to comment on this page.