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

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.


Loebner Keith Lab 4

Page history last edited by xinyi xie 6 years, 2 months ago Saved with comment

Part A



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

     It appears to be reading from 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?

     According to the datasheet, the ADCs on the Atmega32U4 are 10-bit. Since we can read from 0 to 1023, we are using all 10 bits (2^10 = 1024)

Part B


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?

     When the sensor field is clear, the sensor value that is returned is in the 0-40 range. There is a peak between 5-7 cm at ~650, and then the value decreases non-linearly (somewhat exponentially) with distance until the object is approximately 50-70 cm away, and the clear-field reading resumes. This is basically what the datasheet tells us to expect. 

2. Accelerometer


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

     The following code would write the accelerometer data to the LCD screen:


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



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

  lcd.begin(16, 2); 



void loop()



  // print the sensor values:


  // print a tab between values:

  lcd.print("    ");


  // print a tab between values:

  Serial.print("    ");


  // delay before next reading:



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?

     We can store 1024 byte size data samples in a 1K Byte EEPROM (typically 1 kilobyte is referred to as 1000 bytes, but if it's KiloBytes it's usually 1024)

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

     For it to be byte-sized, it must be 8-bit. As we know from previous labs, if we divide the 10-bit number that is read (a base 10 integer) by 4 we will rescale it to an 8-bit number (0 to 255)

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.


     b. Post a link to the Lab 4 Data Logger Hall of Fame.















Comments (1)

xinyi xie said

at 1:24 am on Aug 1, 2014

Good job!

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