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

View
 

Ku_Christine_Lab3

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?

One could change the code to make the song play twice as fast by changing int noteDuration=1000 to half (500). 

b. What song is playing? ;-)

It's the Star Wars theme song!

Part B.

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

The voltage level needed to power the display is 5 volts.

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

I did not make a mistake when wiring the display. It was just a little messy so I tried to make it neater by reducing the amount of wires I overlapped.

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

The line of code I changed was lcd.print("hello, world!");. The text inside the quotation marks for what to print on the LCD was changed from "hello, world!" to "Christine".

Part C.

1.

a. Post a copy of your new code in your lab write-up. (Potentiometer)

int sensorPin = A0;  

int ledPin = 9;  

int sensorValue = 0; 

 

void setup() {

  // declare the ledPin as an OUTPUT:

  pinMode(ledPin, OUTPUT);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);

  sensorValue= constrain(sensorValue, 0, 255);

  analogWrite(ledPin, sensorValue);

}

2.

a. What resistance do you see with a Multimeter when the sensor is flat? When it is bent?

The resistance when the sensor is flat is 8.76 ohms. It is 32.4 ohms when the sensor is bent.

correct but it should be KOhms 

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

Vout= [R2/(R1+R2)]*Vin

Vout= [27000 ohms/(8760 ohms + 27000 ohms)]* 3.3 V

Vout= 2.492 V

 

Vout= [27000 ohms/(32400 ohms+27000 ohms)]* 3.3 V

Vout= 1.500 V

 

The expected voltages based on the sensor resistance are 2.492 volts when it is straight and 1.500 volts when it is bent.

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

The range of the brightness change for the flex sensor is smaller than that of the potentiometer.

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

#include <LiquidCrystal.h>

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

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

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

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

 

void setup() {

  // declare the ledPin as an OUTPUT:

  pinMode(ledPin, OUTPUT);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);

  analogWrite(ledPin, sensorValue);

  lcd.display();

  lcd.print(sensorValue);

  delay(30);

  lcd.clear();

}

3.

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

When I pressed the force sensor the resistance value decreased to 302 ohms. After I released, the resistance value went up to 17.75 mega-ohms. The force sensor has a wide range for resistance values from ohms to mega-ohms.

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

The relationship is a log function.

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

#include <LiquidCrystal.h>

int sensorPin = A0;  

int sensorValue = 0;  

int forcePin= A1;

int forceValue= 0;

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

 

void setup(){

}

 

void loop() {

  lcd.setCursor(0,0);

  sensorValue = analogRead(sensorPin);

  lcd.display();

  lcd.print(sensorValue);

  delay(100);

  lcd.clear();

 

  lcd.setCursor(7,1);

  forceValue= analogRead(forcePin);

  lcd.display();

  lcd.print(forceValue);

  delay(100);

  lcd.clear();

}

4.

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:42 pm on Aug 10, 2015

great job

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