PART A
a. How would you change the code to make the song play twice as fast?
int noteDuration = 500/noteDurations[thisNote];
✓
b. What song is playing? ;-)
Star Wars✓
PART B
a. What voltage level do you need to power your display?
5V✓
b. What was one mistake you made when wiring up the display? How did you fix it?
I thought it wasn't working because I couldn't see but then I noticed that it was very dim and it was working well.
✓
c. What line of code do you need to change to make it flash your name instead of "Hello World"?
lcd.print("Edgar");
PART C
1a. Post a copy of your new code in your lab writeup.
int sensorPin = A0;
int ledPin = 9;
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
sensorValue = sensorValue/4;
analogWrite(ledPin, sensorValue);
}
✓
2a. What resistance do you see with a Multimeter when the sensor is flat? When it is bent?
9.8K when is flat and 20.1K when is bent
✓
2b. What kind of voltages should we expect for the Teensy analog pin based on the sensor resistance?
Using 3.3V and the sensor flat -> Vout = 22k/(9.8k+22k)*3.3V = 2.28V
Using 3.3V and the sensor bent -> Vout = 22k/(20.1k+22k)*3.3V = 1.72V
Using 5V and the sensor flat -> Vout = 22k/(9.8k+22k)*5V = 3.45V
Using 5V and the sensor bent -> Vout = 22k/(20.1k+22k)*5V = 2.61V
✓
2c. How does the range of the LED's brightness change compared to the potentiometer?
It doesn't change because we have a higher resistance than 10K in the sensor
Not quite. The LED brightness will change as the resistance range is not the same.
Try doing a calculation.
2d. Include a copy of your Lowly Multimeter code in your lab write-up.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPin = A0;
int ledPin = 9;
int sensorValue = 0;
double outputValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
lcd.begin(16, 2);
}
void loop() {
sensorValue = analogRead(sensorPin); //read sensor
outputValue = (double)sensorValue*5/1023; //convert sensorValue to voltage
analogWrite(ledPin, sensorValue);
//print in LCD
lcd.setCursor(0, 0);
lcd.print("Output value");
lcd.setCursor(0, 1);
lcd.print(outputValue);
}
✓
3a. What resistance values do you see from your force sensor?
I see changes from M ohms to K ohms, depending on the force applied to the sensor (if more force is applied, the resistance decreases).
✓
3b. What kind of relationship does the resistance have as a function of force applied? (e.g., linear?)
The resistance is inversely proportional to the force applied e.g., The resistance decreases when the force increases.
✓ Try going deeper and figure out the actual mathematical relationship. Hint: Check the datasheet.
3c. Include a copy of your FSR thumb wrestling code in your lab write-up.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPinLeft = A0;
int sensorPinRight = A1;
int sensorValueLeft = 0;
int sensorValueRight = 0;
void setup() {
lcd.begin(16, 2);
}
void loop() {
sensorValueLeft = analogRead(sensorPinLeft);
sensorValueRight = analogRead(sensorPinRight);
lcd.clear();
if(sensorValueLeft > sensorValueRight){
lcd.print("Left winning!");
}
if(sensorValueLeft < sensorValueRight){
lcd.print("Right winning!");
}
}
✓
PART D
a. Make a short video showing how your timer works, and what happens when time is up!
b. Post a link to the Lab 3 Timers Hall of Fame.