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

View

# Stritter Sienna Lab 4

last edited by 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.

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

Serial.begin(9600);

lcd.begin(16, 2);

}

void loop()

{

lcd.clear();

// print the sensor values:

lcd.print("x:");

// print a tab between values:

lcd.print(" y:");

// print a tab between values:

lcd.setCursor(0,1);

lcd.print("z:");

delay(900);

}

## Part C. Count/Time-Based Sensors ## 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. 