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

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Lab 4 - Data Logging

Page history last edited by Brad Haas 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.

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

 

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

  Serial.print(analogRead(xpin));

  // print a tab between values:

  Serial.print("\t");

  Serial.print(analogRead(ypin));

  // print a tab between values:

  Serial.print("\t");

  Serial.print(analogRead(zpin));

  Serial.println();

  // delay before next reading:

  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.print(analogRead(xpin));

  lcd.setCursor(5, 1);

  lcd.print(analogRead(ypin));

  lcd.setCursor(10, 1);

  lcd.print(analogRead(zpin));

  delay(500);

}

 

 

Comments (0)

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