Lab Report _4


Lab Report #4

- Huda Aumir

 

1. Based on the readings from the serial monitor, what is the range of the analog values being read?

 

The range is from 0 to 1024

2. 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, as values on serial monitor were from 0 to 1024. Also solving for x:

2^x=1024 gives x as 10.

3. 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?

 

When nothing was placed over the sensor, there was a reading of 0.5 to 1V. However, when an object was placed in front of the sensor, initially, the voltage increased to a peak value with distance but then began to decrease. The values were non linear and matched with the conclusions from the datasheet.

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

 

#include <LiquidCrystal.h>

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

 

const int xpin = A3;

const int ypin = A2;

const int zpin = A1;

 

int xValue = 0;

int yValue = 0;

int zValue = 0;

void setup()

{

// initialize the serial communications:

Serial.begin(9600);

}

void loop()

{

// print the sensor values:

lcd.begin(16, 2);

int xValue = analogRead(xpin);

Serial.print(xValue);

lcd.print(xValue);

lcd.print(" ");

int yValue = analogRead(ypin);

Serial.print("\t");

Serial.print(yValue);

lcd.print(yValue);

lcd.print(" ");

int zValue = analogRead(zpin);

Serial.print("\t");

Serial.print(zValue);

lcd.print(zValue);

lcd.print(" ");

Serial.println();

delay(1000);

}

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

 


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

 

Pressure sensors from cars, supply the data logger with the current level of traffic. The datalogger uses this data to change the time between the changing of lights to minimize traffic. For example, when more cars are present, the green light stays on for longer than at times with lesser traffic on the road. The data is saved onto EEPROM, and a new set of data can be obtained later, probably after 2 hours or so.

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

 

10,000 bytes can be stored

 

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

 

The data has to be divided by 4, because bytes store data from 0 to 255 while analog data ranges from 0 to 1024

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

 

IMG_0948.MOV