• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.


Cole Hoffer - Lab 4

Page history last edited by xinyi xie 6 years, 5 months ago

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 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 and using 10

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?

As my distance from the sensor decreases, the voltage increases and vice versa. However, when I am moving towards the sensor, the voltage will continue to increase until I am about 3 inches away, in which then I was move closer the voltage will actually decrease. The graph on the datasheet supports my findings, including the close proximity change. 

2. Accelerometer


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

#include <LiquidCrystal.h>



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

int sensorPin_x = A3;

int sensorPin_y = A2; 

int sensorPin_z = A1; 

int sensorValue_x = 0;

int sensorValue_y = 0;

int sensorValue_z = 0;


void setup() {

   lcd.begin(16, 2);




void loop() {

   sensorValue_x = analogRead(sensorPin_x);

   sensorValue_y = analogRead(sensorPin_y);   

   sensorValue_z = analogRead(sensorPin_z);    





















Part C. Count/Time-Based Sensors

1. Rotary Encoder


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


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?

1000 (1KB)

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

It must be a value between 0 and 256 so you would divide your analog value by 4 in order for its maximum to be 256 (1023/4 = 256)

3. Create your data logger!







Comments (1)

xinyi xie said

at 9:46 pm on Jul 30, 2014

Great job!

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