a. Based on the readings from the serial monitor, what is the range of the analog values being read?
0 to 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?
10 bits, using all 10 adds up to 1023
✔
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?
With nothing in front of the sensor, it reads ~70 on the serial monitor. As you have something approach the sensor, it climbs to about 600 about 6 inches from the sensor. After this, getting closer makes it descend to around 250.
✔
How about the rest of the report???
a. Include your accelerometer read-out code in your write-up.
/*
ADXL3xx
Reads an Analog Devices ADXL3xx accelerometer and communicates the
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
http://www.arduino.cc/en/Tutorial/ADXL3xx
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.
*/
// 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)
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
// print the sensor values:
Serial.print(analogRead(xpin));
// print a tab between values:
lcd.print("\t");
lcd.print(analogRead(ypin));
// print a tab between values:
lcd.print("\t");
lcd.print(analogRead(zpin));
lcd.println();
// delay before next reading:
delay(100);
}
NO STATE DIAGRAM -0.5
a. How many byte-sized data samples can you store on the Atmega32U4?
1000
✔
b. How would you get your analog data from the ADC to be byte-sized?
To convert, just map the 10-bit data to 8-bit data.
✔
Here's the code for my data logger:
#include <EEPROM.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
int val = 0;
for (int k = 1; k < 500; k++)
{
val = digitalRead(10)/4;
EEPROM.write(k,val);
delay(150);
}
}
void loop() {
Serial.begin(9600);
int buttonState = 0;
buttonState = digitalRead(8);
if(buttonState == HIGH)
{
for (int j = 1; j < 500; j++)
Serial.print(EEPROM.read(j));
}
}
NO VIDEO (-2)
Comments (1)
xyyue@... said
at 2:01 pm on Aug 11, 2015
Well done.
You don't have permission to comment on this page.