• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.


Gilliland Lab 3

Page history last edited by zahraa@... 5 years, 1 month ago

Part A

a. How would you change the code to make the song play twice as fast?

Make "1000" in "int noteDuration = 1000 / noteDuration[thisNote];" to "500"

b. What song is playing? ;-)

the Star Wars theme song

Part B

a. What voltage level do you need to power your display?

4.7 to 5.5 volts

b. What was one mistake you made when wiring up the display? How did you fix it?

I didn't connect pin 15 to the ground correctly

c. What line of code do you need to change to make it flash your name instead of "Hello World"?

Replace "Hello World" with "Abby" in "lcd.pring("Hello World");"

Part C

1. a. Post a copy of your new code in your lab writeup.

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);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:

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. a. What resistance do you see with a Multimeter when the sensor is flat? When it is bent?

flat: 8-10 Ohms

bent: 20-50 Ohms

correct but it should be KOhms 



b. What kind of voltages should we expect for the Arduino analog pin based on the sensor resistance?

3 volts

c. How does the range of the LED's brightness change compared to the potentiometer?

the potentiometer narrows the range of brightness

Correct but for the voltage divider circuit, Vout = Vin * R2 / (R1 + R2), where the flex sensor could be R1 or R2, depending on how you designed the circuit. 


d. Include a copy of your Lowly Multimeter code in your lab write-up.

#include <LiquidCrystal.h>

int sensorPin = A0;
int ledPin = 13;
int sensorValue = 0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

  pinMode(ledPin, OUTPUT);


void loop() {
  lcd.setCursor(0, 1);
  sensorValue = analogRead(sensorPin);


3. a. What resistance values do you see from your force sensor?

there's less resistance when there is less pressure

b. What kind of relationship does the resistance have as a function of force applied? (e.g., linear?)

at very high and low values the resistance as a function of force is not linear, otherwise it is linear

c. Include a copy of your FSR thumb wrestling code in your lab write-up.

#include <LiquidCrystal.h>

int sensorPin1 = A0;
int sensorValue1 = 0;
int sensorPin2 = A1;
int sensorValue2 = 0;

void setup() {

  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void loop() {

  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

  if(sensorValue2 - sensorValue1 >= 50)
  lcd.print("Player 1 Wins");

if(sensorValue2 - sensorValue1 <= 50)
  lcd.print("Player 2 Wins");


Part D

1. 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.


Comments (1)

zahraa@... said

at 6:16 pm on Aug 10, 2015

well done

You don't have permission to comment on this page.