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


Stritter Sienna Lab 4

Page history last edited by zahraa@... 5 years, 2 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?

According to the datasheet, the Atmega32U4 has a 10 bit ADC. We are using all ten 10 bits, since 2^10 = 1024, giving us the range from 0 to 1023.

Part B. Voltage Varying Sensors 

1a. 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 rises quickly as I move the piece of paper away from the sensor. Once I reach the beginning of the detection range (10cm away, according to the data sheet), the voltage begins to slowly decrease. When the page is outside the detection range (80cm) or when the sensor is pointed to essentially open space, the voltage is basically 0. This is consistent with the voltage vs. distance graph in Figure 5 of the data sheet.

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


 #include <LiquidCrystal.h>

 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:



    lcd.begin(16, 2);



void loop()




  // print the sensor values:



  // print a tab between values:

  lcd.print(" y:");


  // print a tab between values:




  // delay before next reading:




Part C. Count/Time-Based Sensors

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


Part D. Logging values to the EEPROM and reading them back

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

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

1K bytes is 1024 bytes so you can store 1024 byte-sized data samples.

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

The ADC uses 10 bits and a byte is 8 bits. The 2 extra bits in the analog data mean the values can be 2^2 = 4 times as large. To get the analog data to be byte-sized, we must scale by dividing by 4.

3a. Use the lab camera or your own camera/cell phone to record and upload a short demo video of your logger in action.

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





Comments (1)

xyyue@... said

at 2:19 pm on Aug 11, 2015

Well done.

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