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


Rustom Maurice Lab3

Page history last edited by zahraa@... 4 years, 11 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




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


   analogWrite(ledPin, V);




 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



    lcd.print("Left is stronger");





    lcd.print("Right is stronger");




Part D. Timer


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







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.