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

  • Social distancing? Try a better way to work remotely on your online files. Dokkio, a new product from PBworks, can help your team find, organize, and collaborate on your Drive, Gmail, Dropbox, Box, and Slack files. Sign up for free.

View
 

Cole Hoffer - Lab 4

Page history last edited by xinyi xie 5 years, 10 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

 

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

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

   sensorValue_x = analogRead(sensorPin_x);

   sensorValue_y = analogRead(sensorPin_y);   

   sensorValue_z = analogRead(sensorPin_z);    

   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(analogRead(A3));

   Serial.println("Y");

   Serial.println(analogRead(A2));

   Serial.println("Z");

   Serial.println(analogRead(A1));

 

   delay(1000);

   Serial.println();

   Serial.println();

   Serial.println();

}

 

Part C. Count/Time-Based Sensors

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

 

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)

3. Create your data logger!

 

 

 

 

 

 

Comments (1)

xinyi xie said

at 9:46 pm on Jul 30, 2014

Great job!

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