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

Rustom Maurice Lab3

Page history last edited by zahraa@... 8 years, 7 months ago

Part A. Making Sounds

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

I would change the the numerator of the noteDuration parameter by reducing it to 1000/2=500.

 

b. What song is playing? ;-)

Star Wars theme song!! :D

Part B. Writing to the LCD

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

We need 5V input to power up the LCD.

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

I shifted up pins 11-12-13-14 by one hole on the Arduino, then after closed circuit testing I realised what was going wrong and shifted the connection down by one hole.

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

I change the lcd.print() function line to make the LCD flash my name like this:

lcd.print("Maurice Rustom");

Part C. Fancy Inputs

1. Potentiometer

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);

  // turn the ledPin on

  analogWrite(ledPin, sensorValue/30); //divide the value by 30 to get a range of values between 0 and 255 approximately

  delay(sensorValue);

}

 

2. Flex Sensor

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

When the sensor is flat the Multimeter reads a value of 9kOhms. When it is bent its resistance is of 23kOhms.

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

We should use the voltage division equation, the voltage varies between: (3V*9kOhms)/(9kOhms+27kOhms)=0.75V and (3V*23kOhms)/(23kOhms+27kOhms)=1.38V

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

The range of the LED's brightness is smaller than the one we had with the potentiometer.

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

#include <LiquidCrystal.h>

 

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

double sensorPin = A0; 

double ledPin = 13;     

double value=0;

 

void setup() {

     pinMode(ledPin, OUTPUT);

     lcd.begin(16, 2);

}

 

void loop() { 

  double sensorValue = analogRead(A0);

  double V= ((sensorValue/1024)*5);   //adjust the voltage value read on A0

  int flex= (((3*27000)/V)-27000);      //voltage division

   lcd.setCursor(0, 0); 

   lcd.print(flex); 

   analogWrite(ledPin, V);

   delay(1000);  

}

 

 3. Force Sensitive Resistor

 

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

While I am not applying any force on the pressure sensor, the resistance is infinite, but when I start pressurising its top, the resistance drops remarkably reaching approximately zero.

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

The relationship between the resistance and the force I am applying is inversely proportional, the more I apply force the more the resistance drops.

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);

 

void setup() {

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

  lcd.begin(16, 2);

}

 

void loop() {

  int F1= analogRead(A0); //connected left sensor to A0

  int F2= analogRead(A1); //connected right sensor to A1

 

  if(F1>F2){

    lcd.print("Left is stronger");

    delay(1000);

  }

 

  if(F2>F1){

    lcd.print("Right is stronger");

    delay(1000);

  }

}

Part D. Timer

 

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

http://youtu.be/YeWzrfs3juk

 

 

 

 

 

Comments (2)

Maurice said

at 11:49 pm on Aug 2, 2015

I have recently noticed that all my Youtube videos were set as private. I have fixed this error and I have set them all to public.
Sorry for this inconvenience...

zahraa@... said

at 9:10 pm on Aug 4, 2015

good job

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