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

Lab 3 Report for Alex Valderrama

Page history last edited by Alexander Valderrama 7 years, 6 months ago

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

 

change "the constant in the line: int noteDuration = 1000/noteDurations[thisNote];

so it becomes: int noteDuration = 500/noteDurations[thisNote];

 

b. What song is playing? ;-)

 

Star Wars (Main Theme)

 

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 forgot to connect my power column to the +5v so it didn't work the first time I tried. I connected a wire from the power column to +5v

 

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

 

lcd.print("hello, world");

 

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)/4;   
 
  analogWrite(ledPin, sensorValue);        
  // wait for 30 milliseconds to see the dimming effect   
  delay(30);                              
}

 

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

 

23 kOhm when flat, 53 kOhm when bent

 

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

 

1.69 Volts flat, 1.03 Volts bent

 

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

 

The LED's brightness goes from 0 to 255, while the potentiometer can range from 0 to 1023 (the range of analog read)

 

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

 

#include <LiquidCrystal.h>

// 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() {
  lcd.begin(16, 2);
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT); 
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  double value = sensorValue / 1023.0 * (1.69-1.03) + 1.03; 
  lcd.clear();
  lcd.print(value);
  lcd.display();           
  delay(1000); 
}

 

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

 

100 kOhm to .35 kOhm 

 

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

 

Exponential decrease 

 

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

 

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin1 = A0; // select the input pin for the potentiometer
int sensorPin2 = A1;
int ledPin = 13;      // select the pin for the LED
int sensorValue1 = 0;  // variable to store the value coming from the sensor
int sensorValue2 = 0;

void setup() {
  lcd.begin(16, 2);
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT); 
}

void loop() {
  // read the value from the sensor:
  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);
 
  double value1 = sensorValue1; 
  double value2 = sensorValue2;
 
  lcd.clear();
 
  if(value1 > value2) {
    lcd.print("Player 1 wins!");
  } else if (value1 < value2) {
    lcd.print("Player 2 wins!");
  } else {
    lcd.print("It's a tie!");
  }
  lcd.display();           
  delay(1000); 
}

 

a. Make a short video showing how your timer works, and what happens when time is up!

 

Comments (0)

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