Lab 4 Report for Alex Valderrama


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 (hint: where might you look to find this sort of thing)? How many are you using with the range of values you're seeing?

 

10 bits, all of them since 2^10 = 1024 aka 0-1023 range

 

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?

 

The output starts at around 370 and as I move my hand to about 3-4 inches away it increases up to 600. After this it slowly decreases down to background levels of 150 at about 1.5 feet away. Yes it matches up with figure 5's description in the spec.

 

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

 

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// these constants describe the pins. They won't change:
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)

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

void loop()
{
  // print the sensor values:
  int x = analogRead(xpin);
  int y = analogRead(ypin);
  int z = analogRead(zpin);
 
  lcd.clear();
 
  lcd.setCursor(0,0);
  lcd.print("x:");
  lcd.setCursor(2,0);
  lcd.print(x);
 
  lcd.setCursor(8,0);
  lcd.print("y:");
  lcd.setCursor(10,0);
  lcd.print(y);
 
  lcd.setCursor(0,1);
  lcd.print("z:");
  lcd.setCursor(2,1);
  lcd.print(z);
 
  lcd.display();   
  // delay before next reading: 
  delay(500);
}

 

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

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

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

 

1KB is short for 1024 bytes, therefore 1024 samples

 

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

 

Divide 1023 by 4 using integer division

 

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