• 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

# Labs:MartinSanner4

last edited by 7 years ago

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

2^10-1(10 bits, including the 0, so 1023 different possible Values).

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 Arduino.cc website, it has 20 bits. As stated in a., i'm only using 10.

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 decreases with increasing length of view. That turns out to be what i expected, since i imagined it to work as an electronic echolot.

2a.)

31    33    0
16    14    0
6    0    43
35    33    0
0    0    0
33    0    0
27    17    19
15    0    0
31    0    31
0    0    0
0    0    0
9    0    15
25    40    0
41    21    43
37    6    0
2    6    0

/*

acceleration to the computer.  The pins used are designed to be easily

compatible with the breakout boards from Sparkfun, available from:

http://www.sparkfun.com/commerce/categories.php?c=80

The circuit:

analog 0: accelerometer self test

analog 1: z-axis

analog 2: y-axis

analog 3: x-axis

created 2 Jul 2008

by David A. Mellis

modified 4 Sep 2010

by Tom Igoe

This example code is in the public domain.

*/

#include <string>
// 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);
// 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:
lcd.begin(16, 2);
Serial.begin(9600);

}

void loop()

{

// print the sensor values:

// print a tab between values:

Serial.print("\t");
lcd.print ("");

lcd.print(ypin);
// print a tab between values:

Serial.print("\t");
lcd.print("");
delay(1000);
lcd.clear();
Serial.println();

delay(100);

}

http://imageshack.us/scaled/thumb/209/ssgd.jpg

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

Will do so :)

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

Since the Arduino micro has got 1kbyte of EEPROM, we can store 1000 Samples.

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

We have to divide the data by 10, since the analogreadfunction returns a 10 byte-value.