Sharma Naman Lab 4


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?

ANS.

The serial monitor reads 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?

ANS.

The ADC works on a binary number system based on values of 2 raised to some power. Here we see, the values go from 0 to 1024. 
1024=10^10.

hence, we have 10 bits. 

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?

ANS. 

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.

ANS. 

 

  #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);

}

  

Upon tilting the accelerometer in the solder pins direction, then the Y axis decreases, and increases in the other side.

When u tilt 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

  

2. Reading and writing values to the EEPROM

 

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

ANS.

 10^10 that is, 1024

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

ANS.

We need to scale it down -128 to 127.

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