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


Matt Benavente -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?



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 Bit, found on the Atmega32U4 Data sheet. We use all 10 bits, 1023 = 0b1111111111


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?


Test: Peak 2.7V at 8-10cm - Low .018V at 20cm or - 2.7 - 1.13V at 0cm

 Increases from 0->8-10cm, Decreases from 10-20cm


Data sheet: Peak 3V at 8cm - Low .5V at 0cm and 60cm.


2. Accelerometer

360, 115 (50-200 as move up and down), 147

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


// 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:




void loop()


  // print the sensor values:


  // print a tab between values:



  // print a tab between values:




  // delay before next reading:




Part C. Count/Time-Based Sensors

One last type of sensor!


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

You might remember from our Microcontroller Architecture lecture that the Atmega32U4 on Arduino Micro has 1K bytes of internal EEPROM (Wikipedia's EEPROM page).

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

? -0.5

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


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.






Comments (1)

xyyue@... said

at 2:00 pm on Aug 11, 2015

Well done.

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