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

• Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.

View

Cole Hoffer - Lab 4

last edited by 6 years, 5 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?

10 bits and using 10

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?

As my distance from the sensor decreases, the voltage increases and vice versa. However, when I am moving towards the sensor, the voltage will continue to increase until I am about 3 inches away, in which then I was move closer the voltage will actually decrease. The graph on the datasheet supports my findings, including the close proximity change.

2. Accelerometer

#include <LiquidCrystal.h>

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

int sensorPin_x = A3;

int sensorPin_y = A2;

int sensorPin_z = A1;

int sensorValue_x = 0;

int sensorValue_y = 0;

int sensorValue_z = 0;

void setup() {

lcd.begin(16, 2);

Serial.begin(9600);

}

void loop() {

lcd.setCursor(0,0);

lcd.print(sensorValue_x);

lcd.setCursor(7,0);

lcd.print(sensorValue_y);

lcd.setCursor(3,1);

lcd.print(sensorValue_z);

Serial.println("X");

Serial.println("Y");

Serial.println("Z");

delay(1000);

Serial.println();

Serial.println();

Serial.println();

}

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

a. Turn in a copy of your final state diagram

2. Reading and writing values to the EEPROM

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

1000 (1KB)

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

It must be a value between 0 and 256 so you would divide your analog value by 4 in order for its maximum to be 256 (1023/4 = 256)