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


Annie Pa Lab 4

Page history last edited by Vivien Tsao 6 years, 11 months ago


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




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 ADC has 10 bits of resolution, which is consistent with the previous answer (2^10), meaning that we are using all 10.


Part B


1. 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 increases from -250 to 9000, then decreases back to a negative number as an object slowly approaches the sensor. This matches with the graphs presented in the data sheets.


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


#include <LiquidCrystal.h>


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


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





void loop()



  lcd.print("X: ");


  lcd.print("    Y: ");



  lcd.print("     Z: ");




 photo 2013-07-24195812_zpsa267a451.jpg


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


No Force --> Sensing hand --> Records Data

Force Press  --> Shows Data


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


1000 bytes


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


Divide by 4. Since analog data is from 0-1024, dividing by 4 reduces it to the  0-255 range.




Comments (1)

Vivien Tsao said

at 4:17 pm on Aug 10, 2013

Good job!

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