Lab 4 - Cam Bennett


Make a Data Logger!

 

 

Part A. Writing to the Serial Monitor

 

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

     0 - 1023.

b. How many bits of resolution does the analog to digital converter (ADC) on the Atmega32U4 have (hint: where might you look to find this sort of thing)? How many are you using with the range of values you're seeing?
 
    The ADC has 8-10 bits of resolution, according to its datasheet. 2^10 is 1024, so all of the resolution is being used.

 

 

Part B. Voltage Varying Sensors

 

1. IR Distance Sensor

 

a. Describe the voltage change over the sensing range of the sensor. A sketch of voltage vs. distance would work also. Does it match up with what you expect from the datasheet?

 

 

     From 0 to 10 centimeters, the voltage rises from around 250 (when the object read is as close to the sensor as possible) to about 600(10cm away). After this, the voltage decreases as the object read gets farther and farther away, bottoming out at about 40 when the object is about 3 feet away. This lines up with what the datasheet says(that the sensor works best from 10 to 80cm).

2. Accelerometer

 

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

#include <LiquidCrystal.h>

const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models)
const String x = "x: ";
const String y = "y: ";
const String z = "z: ";
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup(){
  lcd.begin(16, 2);
  Serial.begin(9600);
}

 

void loop(){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(x + analogRead(xpin));
  lcd.print("\t");
  lcd.print(y + analogRead(ypin));
  lcd.setCursor(0,1);
  lcd.print(z + analogRead(zpin));
  delay(100);
}

  

Part C. Count/Time-Based Sensors

a. Upload a picture of your rotary encoder in action!

http://www.youtube.com/watch?v=9HpLfwD_2xo&feature=g-upl

Part D. Logging values to the EEPROM and reading them back

1. Design your logger

a. Turn in a copy of your final state diagram.

 

2. Reading and writing values to the EEPROM

a. How many byte-sized data samples can you store on the Atmega32U4?

1024

b. How would you get your analog data from the ADC to be byte-sized?

Cast the address of my data to byte*, then pass that to the write function and read each byte using array notation.

3. Create your data logger!

a. Use the lab camera or your own camera/cell phone to record and upload a short demo video of your logger in action.

http://www.youtube.com/watch?v=nbavKyNDfKo&feature=g-upl