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

last edited by 8 years, 1 month ago

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

it goes from 0 to 1036

✓ Did it really go above 1024?

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?

the resolution of the atmega32U4 is of 1024 bits or 1 kb

Not quite. 1 bit represents integer value of 2. so to get 1024, you will have 2^10 bits = 1024.

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?

mi sensor was a bit weird so it went from 0.6 to 4.2 and as I distanced away from it gradually the voltage would go up lineally but sometimes it would suddenly skip 0.3 volts up or it would suddenly increase or decrease.

Check your wiring or change a known working sensor to check if it is a sensor issue.

*/

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

void setup()

{

// initialize the serial communications:

Serial.begin(9600);

}

void loop()

{

// print the sensor values:

// print a tab between values:

Serial.print("\t");

// print a tab between values:

Serial.print("\t");

Serial.println();

delay(100);

}

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

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

1024

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

1024/4 = 256