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

Cameron's Lab 4

Page history last edited by camerons 13 years, 11 months ago

Cameron Schaeffer

Lab 4

a. What line(s) of code do you need to change?

Change the line    “int ledPin = 13;”  to   “int ledPin = 9;”

b. How would you make the LED on the Teensy light up instead

Change it to “int ledPin=11; “   instead.

a. Based on the readings from the serial monitor, what is the range of the analog values being read?

0 to 1023.

b. How many bits of resolution does the analog to digital converter (ADC) on the Atmega32U4 have?

10 bits of resolution because 2^10 = 1024.

a. What kind of voltages should we expect? 

If the flex sensor is at 10k (its min) we should get Vout = 22/(22+10)*5V = 22/32*5 = 3.44V

If the flex sensor is at 110k (its max) we should get Vout = 22/(110+22)*5V = 22/132*5=.83V

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

There is a smaller range because there is a smaller range of output voltages (the potentiometer was capable of 0V to 5V. The flex sensor circuit is capable of .83 to 3.44V)

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

// include the library code:

#include <LiquidCrystal.h>

 

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

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

 

void setup() {

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

  lcd.begin(16, 2);

  // Print a message to the LCD.

}

 

int lastRead=0;

 

void loop() {

  int a = analogRead(0);

  int m=millis();

  if(m-lastRead>500 || lastRead-m>500)

  {

  lcd.clear();

  // set the cursor to column 0, line 1

  // (note: line 1 is the second row, since counting begins with 0):

  lcd.setCursor(0, 1);

  // print the number of seconds since reset:

  double voltage=(a*5)/1023.0;

  lcd.print(voltage);

  lastRead=m;

  }

}

 

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

 

 

// include the library code:

#include <LiquidCrystal.h>

 

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

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

 

void setup() {

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

  lcd.begin(16, 2);

  // Print a message to the LCD.

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

}

 

int lastRead=0;

 

void loop() {

  int a = analogRead(0);

  int b = analogRead(1);

  int m=millis();

  if(m-lastRead>500 || lastRead-m>500)

  {

  lcd.clear();

  // set the cursor to column 0, line 1

  // (note: line 1 is the second row, since counting begins with 0):

 

  lcd.setCursor(0, 1);

  // print the number of seconds since reset:

  lcd.print("<-----");

  lcd.print(a);

  lcd.setCursor(0,0);

  lcd.print(b);

  lcd.print("----->");

 

  lastRead=m;

  }

}

 

a. Describe the voltage change over sensing range of the sensor.

 

It starts off very low if you put something RIGHT in front of it, but rises very very quickly up to about 2.6V for my wall which occurs when you put it at about 5cm away. After this it falls down somewhat quickly until 25cm away (about 1.25V) at which it continues to fall at a much slower rate. Its max range is about 1m, and then drops to .01V output idle.

 

 

a. Include your accelerometer read-out code in your write-up.

 

 

// include the library code:

#include <LiquidCrystal.h>

 

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

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

 

void setup() {

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

  lcd.begin(16, 2);

  // Print a message to the LCD.

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

}

 

int lastRead=0;

 

void loop() {

  int a = analogRead(0);

  int b = analogRead(1);

  int m=millis();

  if(m-lastRead>300 || lastRead-m>300)

  {

  lcd.clear();

  // set the cursor to column 0, line 1

  // (note: line 1 is the second row, since counting begins with 0):

  lcd.setCursor(0,0);

  lcd.print("X:"+ analogRead(2));

  lcd.print(" Y:"+ analogRead(1));

  lcd.setCursor(1,1);

  lcd.print(" Z:"+ analogRead(0));

 

 

  lastRead=m;

  }

}

 

See my data logger page!

Cameron's Data Logger

 

Comments (0)

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