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

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.

View
 

lab3 report

Page history last edited by zahraa@... 4 years, 11 months ago

PART A

a. change the int pauseBetweenNotes = noteDuration * 1.3; to 0.65

Correct, but that might not address the question entirely, because the notes themselves wouldn’t be shorter, only the durations between them

 

 

b. star wars track

✔ 

 

PART B

 

  1. 5.0V

    ✔ 

  2. I did not sort well the LCD so the display was kind of wired, but then I found the mistake and corrected it.

  3. lcd.print(“Jiahao guo”);

    ✔ 

 

  1.  

 

 

 

PART C

a. int ledPin = 13; // select the pin for the LED

int fadeAmt = 0;

int fadeConstant =0;

int brightness =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:

fadeAmt = analogRead(sensorPin);

fadeAmt = (int)fadeAmt*.20;

Serial.begin(8000);

✔ 

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.

 

 

 

 

a. 573ohms 545

about 10K Ohms when flat, about 10K Ohms if bent one way, and about 50K Ohms if bent the other way

-0.5

b. 3.3V

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.

 

 

c. it pretty much changes the brightness of the LED

d.#include <LiquidCrystal.h>

 

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

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

int analogPin= 3;

 

void setup() {

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

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print(analogRead(analogPin));

}

 

void loop() {

// Turn off the display:

lcd.clear();

delay(500);

lcd.print(analogRead(analogPin));

// Turn on the display:

lcd.display();

delay(500);

}

 

3a. 325Ohms

Resistance should be very high (infinite or M Ohms) when the FSR is not pressed. Resistance should lower to a few hundred Ohms, or low K Ohms, when pressed hard. -0.5

 

3b. I think it is a linear relationship, since the more force you add on to the sensor, the resistance becomes larger and larger.

3c. #include <LiquidCrystal.h>

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

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

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

int sensorPinR = A1; // select the input pin for the potentiometer

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

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

int sensorValueR = 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);

pinMode(ledPin, OUTPUT);

}

void loop() {

// read the value from the sensors:

sensorValueL = analogRead(sensorPin1);

sensorValueR = analogRead(sensorPin2);

if(sensorValue1 > sensorValue2)

lcd.print("LEFT");

else if(sensorValue1 < sensorValue2)

lcd.print("RIGHT");

else

lcd.print("Tie");

}

 

here is the youtube link:

 

https://youtu.be/k4wt7_41Tlc

Comments (1)

zahraa@... said

at 6:18 pm on Aug 10, 2015

good job

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