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

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.


Rittida Herabat Lab 4

Page history last edited by zahraa@... 4 years, 11 months ago



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

0 to 1024

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 has 10 bits of resolution or 1024 steps. We are using the whole range (all 10 bits).



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 starts off at 0.977 v at the distance 0. The voltage increases to about 1.95 v at about the distance of 15 cm. Then it starts decreasing value. The graph is the shape of a bell.  The shape of the graph matches the graph in the datasheet, but the values are not the same.


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


 // initialize the serial communications:



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

 lcd.begin(16, 2);




void loop()


   // Print a message to the LCD.


lcd.print(" ");


 // print a tab between values:

lcd.print(" ");



 // delay before next reading:


  lcd.setCursor(0, 0);





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 bytes.

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

You have to divide by four.


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)

xyyue@... said

at 2:16 pm on Aug 11, 2015

Well done.

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