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

• Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.

View

# lab3report-sethu

last edited by 7 years, 11 months ago

EE47 INTERACTIVE DESIGN

LAB-3 REPORT

NAME:SETHU KOVENHAN BOOPATHY JEGATHAMBAL

ID NO:05921102

Part A. Making Sounds

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

#include "pitches.h"

// notes in the melody:

int melody[] = { NOTE_D3,NOTE_D3,NOTE_D3,NOTE_G3,NOTE_D4,NOTE_C4,NOTE_B3,NOTE_A3,NOTE_G4,NOTE_D4, NOTE_C4,NOTE_B3,NOTE_A3,NOTE_G4,NOTE_D4,NOTE_C4,NOTE_B3,NOTE_C4,NOTE_A3,0};

// note durations: 4 = quarter note, 8 = eighth note, etc.:

int noteDurations[] = { 10,10,10,2,2,10,10,10,2,4, 10,10,10,2,4,10,10,10,2,4};

void setup() {

// iterate over the notes of the melody:

for (int thisNote = 0; thisNote < 20; thisNote++) {

// to calculate the note duration, take one second

// divided by the note type.

//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.

int noteDuration = 1000/noteDurations[thisNote]/2;

tone(8, melody[thisNote],noteDuration);

// to distinguish the notes, set a minimum time between them.

// the note's duration + 30% seems to work well:

int pauseBetweenNotes = noteDuration * 1.30;

delay(pauseBetweenNotes);

// stop the tone playing:

noTone(8);

}

}

Highlighted lines are edited . This decreases the time and increases the speed.

b.What song is playing? ;-)

Haven’t heard of it. Sorry !!!!

## Vcc is 5V.Back light is 3V

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

Wrong connection of wire (from pin 2).I fixed it by checking the circuit again.

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

change line

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

as

lcd.print("sethu!"); // Picture shows “Stanford rocks”

## Part C. Fancy Inputs

*/

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:

analogWrite(13,sensorValue/4);

}

2. Flex Sensor

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

Flat condition:8.5kohm Bent condition:18-19 kohm

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

Voltage depends on the amount of bending of sensor.Voltage is continuous and varying.

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

To convert the range to match with the input value we have to use map function in the code.

Usually led brightness depends linearly on the value of 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);

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:

lcd.begin(16,2);

pinMode(ledPin, OUTPUT);

}

void loop() {

// read the value from the sensor:

lcd.print(sensorValue);

}

### 3. Force Sensitive Resistor

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

Maximum value is in some Mohm range and minimum is in 10k range

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

Resistance value varies inversely with applied force ,when force is high resistance is minimum.

They vary in log scale.

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

My code:

// one who holds with more force wins

// I used two LED for 2 players.

int sensorPin1 = A0; // select the input pin for the fsr1

int sensorPin2 = A1; // // select the input pin for the fsr1

int ledPin1 = 13; // select the pin for the LED for player 1

int ledPin2 = 8; // select the pin for the LED for player 1

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

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

if (sensorValue1>sensorValue2)

digitalWrite(ledPin1,HIGH);

delay(500);

else

digitalWrite(ledPin2,HIGH);

delay(500);

}

Part D: