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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Annie Pa Lab 4

Page history last edited by Vivien Tsao 10 years, 7 months ago

 

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

 

0-1023

 

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 ADC has 10 bits of resolution, which is consistent with the previous answer (2^10), meaning that we are using all 10.

 

Part B

 

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 voltage increases from -250 to 9000, then decreases back to a negative number as an object slowly approaches the sensor. This matches with the graphs presented in the data sheets.

 

2.  a. 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;                  // x-axis of the accelerometer

const int ypin = A2;                  // y-axis

const int zpin = A1;                  // z-axis (only on 3-axis models)

 

void setup()

{

  lcd.begin(16,2);

}

 

void loop()

{

  lcd.clear();

  lcd.print("X: ");

  lcd.print(analogRead(xpin));

  lcd.print("    Y: ");

  lcd.print(analogRead(ypin));

  lcd.setCursor(0,1);

  lcd.print("     Z: ");

  lcd.print(analogRead(zpin));

  delay(1000);

}

 photo 2013-07-24195812_zpsa267a451.jpg

 

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

 

No Force --> Sensing hand --> Records Data

Force Press  --> Shows Data

 

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

 

1000 bytes

 

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

 

Divide by 4. Since analog data is from 0-1024, dividing by 4 reduces it to the  0-255 range.

 

 

 

Comments (1)

Vivien Tsao said

at 4:17 pm on Aug 10, 2013

Good job!

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