• 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

Lab 4 - Data Logging

last edited by 7 years, 2 months ago

Data Logging

Part A.  Writing to the Serial Monitor

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

I am seeing analog values of approximately 0 - 667, which is what I would expect.

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, as reported on the data sheet at the following website: http://www.atmel.com/Images/7766s.pdf. We are using all 10 bits, as we read in values from 0 to 1023, and 1023 is 2^10.

Part B.  Voltage Varying Sensors

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

We are seeing voltage values of around 0.12 to 3.20 V. This matches up almost exactly to what was on the data sheet.

#include <LiquidCrystal.h>

// 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)

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

void setup()

{

// initialize the serial communications:

Serial.begin(9600);

lcd.begin(16, 2);

}

void loop()

{

// print the sensor values:

// print a tab between values:

Serial.print("\t");

// print a tab between values:

Serial.print("\t");

Serial.println();

lcd.setCursor(0,0);

lcd.print("X");

lcd.setCursor(5, 0);

lcd.print("Y");

lcd.setCursor(10, 0);

lcd.print("Z");

lcd.setCursor(0,1);

lcd.setCursor(5, 1);

lcd.setCursor(10, 1);

delay(500);

}