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

lab 3 ian

Page history last edited by Ian 6 years, 11 months ago

Lab 3 

EE 47

 

John “Ian” Kelly

Got sick for 1.5 weeks, thus this may have been posted a bit late. David said this was okay. 

 

Part A

 

  1. Change code to make song 2x?

 

int noteDuration = 2000/noteDurations[thisNote];

 

  1. Star wars theme song

 

 

Part B

 

  1. What voltage level do u need to power display? 

 

4.5 V but 5v is okay. 

 

  1. Had the arduino and pot oriented the wrong way so wiring was very difficult- thought about all the connections and aligned the digital side of arduino next to the lcd (since most wiring would be between these two chip edges. )
  2. LINE 50  needs to be changed to “Ian Kelly” 

 

PART C

 

1. potentiometer

a. 

 

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

int ledPin = 10;      // 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

  //divided by 3 because light faded fully 3 times with one turn of 

 // pot which meant analogRead value was 3x too big.  

  analogWrite(ledPin, sensorValue/3);  

  // stop the program for <sensorValue> milliseconds:

  delay(10);                  

}

 

 

  1. flex sensor 

 

  1. When flat i read 10.2 k ohms. When bent I read 20.1 k ohms.
  2.   when flat: 24k/ 34k x 3 = 2.11 volts. when bent: 24k/44k x 3 = 1.6 volts
  3. The range is much less when compared to the potentiometer which makes sense because the proportional change in resistance is much less. 

 

  1. lowly multimeter code: 

 

#include <LiquidCrystal.h>

 

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

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

 

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

int ledPin = 10;      // 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);  

lcd.begin(16,2);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin)*2;    

  // turn the ledPin on

  lcd.setCursor(0,0);

  analogWrite(ledPin, sensorValue);

  lcd.print(sensorValue);  

  // stop the program for <sensorValue> milliseconds:

  delay(0);                  

}

 

 

  1. force resistor

 

a. from 200k to .4 ohms. 

b. it is inverse logarithmic. ie the more force the smaller the resistance. but applying force from 10k to 1k  ohms is way easer than from 10 to 1 ohm. 

 

c. thumb wrestle code: 

 

 

// include the library code:

#include <LiquidCrystal.h>

 

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

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

 

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

int FsensorPin = A1;

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

int FsensorValue = 0;

 

void setup() {

  // declare the ledPin as an OUTPUT:

 

lcd.begin(16,2);

}

 

void loop() {

  // read the value from the sensor:

  sensorValue = analogRead(sensorPin);

  FsensorValue = analogRead(FsensorPin);  

  // turn the ledPin on

  lcd.setCursor(0,0);

 // analogWrite(ledPin, sensorValue);

  lcd.print(sensorValue);  

  // stop the program for <sensorValue> milliseconds:

  lcd.setCursor(0,1);

  lcd.print(FsensorValue);

 

  lcd.setCursor(4,1);

  lcd.print("winner: ");

  lcd.setCursor(12,1);

  if(sensorValue > FsensorValue) {

    lcd.print("A0");  

  }

  else {

    lcd.print("A1");

  }

 

    delay(0);        

 

}

 

Part D timer

 

 

 

http://www.youtube.com/edit?ns=1&video_id=USkPJcwlGyY

Comments (0)

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