Aaron Egbert: Lab 4


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

The analog values, based on readings from the serial monitor, rang from 717 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?

The analog to digital converter has 10 bits of resolution (0-1023). I am using 10 bits with the values I am seeing.

 

------------------------------------------------------------------------------------------------------------------

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 voltage is at a low number (typically less than a hundred) when it looks at an object far away. Then as it moves closer to an object, it will increase in numbers linearly, then slow down around 650, and then decrease dramatically as the sensor gets extremely close to the wall.

 

---------------------------------------------------------------------------------------------------------------------

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

/*

 ADXL3xx

 

 Reads an Analog Devices ADXL3xx accelerometer and communicates the

 acceleration to the computer.  The pins used are designed to be easily

 compatible with the breakout boards from Sparkfun, available from:

 http://www.sparkfun.com/commerce/categories.php?c=80

 

 http://www.arduino.cc/en/Tutorial/ADXL3xx

 

 The circuit:

 analog 0: accelerometer self test

 analog 1: z-axis

 analog 2: y-axis

 analog 3: x-axis

 

 created 2 Jul 2008

 by David A. Mellis

 modified 4 Sep 2010

 by Tom Igoe 

 

 This example code is in the public domain.

 

*/

 

// 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);

 

// 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()

{

  // initialize the serial communications:

  Serial.begin(9600);

  lcd.begin(16,2);

  lcd.display();

}

 

void loop()

{

  // print the sensor values:

  lcd.setCursor(3,1);

  lcd.print(analogRead(xpin));

  // print a tab between values:

  lcd.setCursor(7,1);

  lcd.print(analogRead(ypin));

  // print a tab between values:

  lcd.setCursor(11,1);

  lcd.print(analogRead(zpin));

  // delay before next reading:

  delay(100);

}

 

------------------------------------------------------------------------------------------------------

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?

1000 byte-sized data samples

 

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

I would map the values of the Counter (0-16383) to an 8-bit size (0-255)