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

  • Social distancing? Try a better way to work remotely on your online files. Dokkio, a new product from PBworks, can help your team find, organize, and collaborate on your Drive, Gmail, Dropbox, Box, and Slack files. Sign up for free.

View
 

CameronSteinfeld_Lab(3)

Page history last edited by Cameron Steinfeld 6 years, 10 months ago

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

If you change the value of intNoteDuration from  int noteDuration = 1000/noteDurations[thisNote]; to int noteDuration = 500/noteDurations[thisNote]; the song will play 

twice as fast.

b. What song is playing? ;-)

The orignal song is "shave and  a haircut two bits" the next song that is played is "The Starwars theme".

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

5 volts of power is required to power the display, and 3 to 3.3 Volts is required to power the backlight. 

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

One mistake that I made when wiring was instead of hooking up LCD pin 14 to Arduino pin 2, I accidentally attatched LCD pin 13 to Arduino pin 2 this put 4 of my wires 

off by one pin.  I remedied this by moving all the wires up one pin on the LCD.

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

To change what the LCD displays you can change the lcd.print("Hello, world") line to lcd.print("whatever you want"), or lcd.print(your name).

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;

  // give the pin sensor value.

  analogWrite(ledPin, sensorValue);            

 

}

 

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

When the flex sensor is flat it is at about 9.5 K Ohms of resistance and when it is bent it is at about 13 K Ohms of resistance.

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

We would expect to see around 3.6 volts of output when the sensor is flat, and 3.2 volts of output when the sensor is bent.  This is assuming the 9.5 K Ohms and 13 K ohms

of resistance that I observed.

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

With the potentiometer, I think the range was larger than with the sensor.  The potentiometer could make the light completely bright and completely dark, whereas the 

the flex sensor was slightly harder to take the LED to the extremes of bright and dark.

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

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

 

// include the library code:

#include <LiquidCrystal.h>

 

// initialize the library with the numbers of the interface pins

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

 

 

void setup() {

  // declare the ledPin as an OUTPUT:

  pinMode(ledPin, OUTPUT); 

  lcd.begin(16,2);

  lcd.println(sensorValue);

  Serial.begin(9600);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);

 

  lcd.setCursor(0,0);

  lcd.println(sensorValue);

 

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

The range of the force sensor is from about 200 kohms when untouched to 200 ohms when squished.

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

The relationship between force applied and resistance is not linear, it appears to act as a kind of bell curve. As little force is applied, the resistance increases slowly, then as

more force is applied the resistance will increase quite quickly, up until a certain point of resistance where the rate of increase will gradually slow down again.

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

int sensorPin1 = A1;

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

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

int sensorValue1 = 0;

// include the library code:

#include <LiquidCrystal.h>

 

// initialize the library with the numbers of the interface pins

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

 

 

void setup() {

  // declare the ledPin as an OUTPUT:

  lcd.begin(16,2);

  Serial.begin(9600);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);

  sensorValue1 = analogRead(sensorPin1);

  lcd.setCursor(0,0);

  if (sensorValue1 > sensorValue) {

    lcd.print("Player 2 is winning");

  } else {

    lcd.print("player 1 is winning");    

 

  }               

}

 

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

 


 

 

 

Comments (1)

Vivien Tsao said

at 12:14 am on Jul 29, 2013

Good job! 10/10

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