| 
  • 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
 

COsorio Lab 4

Page history last edited by Benjamin Tee 8 years, 2 months ago

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

The serial monitor returns values between 7 and 1017 when I apply voltages between ~0 and 4.87V. It can read up to 5V.

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?

According to the data sheet, the ADC has 10 bit resolution

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?

The rate of change tapers off as the distance increases. This follows the expected graph from the datasheet.


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

/*

Accelerometer to Serial

I used the graph example code by David A Mellis to start.

created 2006

by David A. Mellis

modified 9 Apr 2012

by Tom Igoe and Scott Fitzgerald

 

Takes data from an accelerometer connected to A1, A2, and A3 and writes the readings to the serial monitor.

 

*/

 

int power=0;

int ground=1;

int x;

int y;

int z;

 

void setup() {

pinMode(power, OUTPUT);

pinMode(ground, OUTPUT);

digitalWrite(power, HIGH);

digitalWrite(ground, LOW);

delay(500);

// initialize the serial communication:

Serial.begin(9600);

}

 

void loop() {

// send the value of analog input 0:

x=analogRead(A1);

y=analogRead(A2);

z=analogRead(A3);

 

Serial.print("x ");

Serial.print(x);

Serial.print("\ty ");

Serial.print(y);

Serial.print("\tz ");

Serial.print(z);

Serial.print("\n");

// wait a bit for the analog-to-digital converter

// to stabilize after the last reading:

delay(10);

}

 

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

1024 (1KB)

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

     You would just truncate the 2 least significant bits. This is the same as a bit shift by 2 to the right or dividing by 4.


 

Comments (1)

Benjamin Tee said

at 12:21 am on Aug 13, 2012

Great job!

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