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

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Angeles Cesar Lab4

Page history last edited by xinyi xie 6 years ago

Part A.  Writing to the Serial Monitor

 

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

I can see values from 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. The 10 bits because 2^10 = 1024 from 0 to 1023

Part B. Voltage Varying Sensors 

 

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?

 

Yes, when I put a white sheet near the sensor it outputs values near 0 (2,3) when I move it away, the sensor outputs greater values that grows fast with the change, but after, the values start decreasing but slowly, just as the graph in the datasheet

 

2. Accelerometer

 

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

 

Here is the code in which I add which value corresponds to each axis.

 

 

/*

 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.

 

*/

#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 = A0;                  // 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:

 

  lcd.setCursor(0,0);

  lcd.print("x:");

  lcd.setCursor(3,0);

  lcd.print(analogRead(xpin));

  // print a tab between values:

 

  lcd.setCursor(7,0);

  lcd.print("Y:");

  lcd.setCursor(10,0);

  lcd.print(analogRead(ypin));

 

  // print a tab between values:

 

  lcd.setCursor(6,1);

  lcd.print("Z:");

  lcd.setCursor(9,1);

  lcd.print(analogRead(zpin));

  Serial.print(analogRead(zpin));

  Serial.println();

  // delay before next reading:

  delay(200);

}

 

 

When I tilt the accelerometer in the solder pins direction, then the Y axis decreases, and increases in the other side.

 

When I tilt the accelerometer by the shortest sides, that means in the same line of the shortest sides the X axis decreases and increases. 

 

Part C. Count/Time-Based Sensors

 

1. Rotary Encoder

 

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

 

 

Part D. Logging values to the EEPROM and reading them back

 

1. Design your logger

 

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

 

 

 

2. Reading and writing values to the EEPROM

 

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

1024 bytes

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

First by scaling them to -128 to 127 and then by casting the data in the program

a. Use the lab camera or your own camera/cell phone to record and upload a short demo video of your logger in action.

 

 

 

 

 

Comments (1)

xinyi xie said

at 5:16 pm on Jul 30, 2014

Great job!

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