EE47 - Lab 4


A

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?

?? Check the datasheet if in doubt...

B

1

 

2

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

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
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); 
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop() {
  // print the sensor values:
  lcd.setCursor(0,1);
  lcd.print(analogRead(xpin));
  lcd.setCursor(7,1);
  lcd.print(analogRead(ypin));
  lcd.setCursor(13,1);
  lcd.print(analogRead(zpin));
  //print x,y,z
  lcd.setCursor(1,0);
  lcd.print("X");
  lcd.setCursor(8,0);
  lcd.print("Y");
  lcd.setCursor(14,0);
  lcd.print("Z");
  lcd.println();
  // delay before next reading:
  delay(100);
}

C

1

a. Upload a picture of your rotary encoder in action!


D

1

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

 

2

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?

??

 

Video:

http://www.youtube.com/watch?v=06YHgRXPkVw&feature=youtu.be