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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Lab 3 - Aziz

Page history last edited by Aziz Sayigh 10 years, 11 months ago

Part A. Making Sounds

 

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

Double the note duration numbers (// note durations: 4 = quarter note, 8 = eighth note, etc.:)

 

b. What song is playing? ;-)

Star Wars theme! 

 

 

Part B. Writing to the LCD

 

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

5V per the spec sheet.

 

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

The voltage divider with the POT was tricky.  Didn't mess up, but had to ask for help.

 

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

void setup() {

  // set up the LCD's number of columns and rows: 

  lcd.begin(16, 2);

  // Print a message to the LCD.

  lcd.print("hello, world!");

}

 

 

Part C. Fancy Inputs

 

2. Potentiometer

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

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);    

  // turn the ledPin on

  analogWrite(ledPin, sensorValue)

  delay(1000);          

  // turn the ledPin off:        

  analogWrite(ledPin, 0) 

  // stop the program for for <sensorValue> milliseconds:

    delay(1000);               

}

 

 

2. Flex Sensor

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

Flat: ~25k Ohms.  Bent: ~60k Ohms

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

When Flat, the resistence is approx equal to the other resistor, so 50% of voltage should flow to the analogue.  2.5 V

When bent, (24/(24+60))*5V = 1.4V

 

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

The POT has a higher range of resistances and so will create a higher range of brightness

 

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

 

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

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

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

 

void setup() {

  // set up the LCD's number of columns and rows: 

  lcd.begin(16, 2);

  // Print a message to the LCD.

  lcd.print("hello, world!");

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);    

  // turn the ledPin on

  lcd.print(sensorVal);   

}

 

 

 

 

3. Force Sensitive Resistor

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

0.1kOhms-75kOhms

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

It is linear

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

 

 

 

 

 

 

Comments (0)

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