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

  • Want to organize your cloud files? Sign up for a free webinar to see how Dokkio (a new product from PBworks) can help you find, organize, and collaborate on your Drive, Gmail, Dropbox, and Slack files: Weds, May 27 at 2PM Eastern / 11AM Pacific
View
 

Michelle Lab4

Page history last edited by Michelle Lee 9 years ago

Part a

 

part 1
a. Post a copy of your new code in your lab writeup.
int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 9;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin)/4;   
  // turn the ledPin on
  analogWrite(ledPin, sensorValue);  

}

part 2

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 Atmega328 have? How many are you really using with the range of voltages you're seeing?

 

part 3

 

a. What resistance do you see with a Multimeter when the sensor is flat? When it is bent?

9 kohm - 33kOhm

 

b. What kind of voltages should we expect for the Arduino pin based on the sensor resistance? 

1.4517 V - 3.9 V

 

V= IR

At 9 kohms

I=0.0001613 amp

I*9,000 ohms = 1.4517V

 

at 33 kohms

I=0.0001190 amp

I*33,000=3.9 V

 

 

c. How does the range of the LED's brightness change compared to the potentiometer?

 

It's a lot smaller.  The range for potentiometer is 0-1023, whereas the flex sensor has a range from 440-719

 

 

Incorporate the LCD or serial monitor into your fading LED/potentiometer code so that you can read out the exact analog value that you are reading in on Analog Pin 0. It's your own lowly multimeter! Change the LED fading code values so that you get the full range of output voltages from using your Flex sensor.

 

d. Include a copy of your Lowly Multimeter code in your lab write-up.




int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 9;      // select the pin for the LED
long sensorValue = 0;  // variable to store the value coming from the sensor
long sensorMax = 750;
long sensorMin = 450;

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
  Serial.begin(9600);
}

void loop() {
  // read the value from the sensor:
     sensorValue = (((long)analogRead(sensorPin)- sensorMin)*255) /((sensorMax-sensorMin));
     if (sensorValue < 0)
       sensorValue = 0;
     if (sensorValue > 255)
       sensorValue = 255;
     Serial.println(sensorValue);
     delay(10);
// turn the ledPin on
  analogWrite(ledPin, sensorValue);  
}

part 4

 

a. What resistance values do you see from your force sensor?

0.5 kOhm

 

b. Include a copy of your FSR thumb wrestling code in your lab write-up.

 

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
}

void loop() {
  // send the value of analog input 0:
  String string = analogRead(A0);
  string.concat("  vs   ");
  string.concat(analogRead(A3));  
  Serial.println(string);
  // wait a bit for the analog-to-digital converter
  // to stabilize after the last reading:


}
part B

 

1.

a. Describe the voltage change over sensing range of the sensor.

The voltage at first is low (because the light can't be reflected into the receiver when your hand is too close), then spikes to around 2.7 at around 10cm -15 cm. Then the voltage drops exponentially to the distance.

 

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

 

 

363    320    346
362    317    348
361    315    348
354    314    350
354    315    351
355    316    350
353    315    350
353    315    350
351    314    350
352    315    351
352    314    350
352    314    352
354    316    348
373    322    343
380    331    344
394    357    341
390    368    340
388    377    339
383    385    339
376    392    341
368    399    342
354    399    339
348    402    343
342    401    344
340    400    343
342    402    343
344    401    343
350    403    344
357    405    347
369    399    344
385    386    348
387    367    346
391    357    343
389    353    349
391    355    341
377    349    310
367    354    301
370    356    307
367    358    307
369    358    306
372    357    307
373    358    306
385    354    326
387    355    335
391    359    350
384    360    379
374    359    388
363    360    390
359    359    392
356    360    391
355    360    392
354    360    392
353    361    393
352    360    392
353    361    392
352    361    393
352    361    391
357    361    392
370    360    388
382    357    366
387    352    337
387    355    327
383    358    323
376    359    312
370    360    307
367    362    308
374    360    309
375    358    308
375    357    321
383    358    315
378    356    315
382    360    312
379    357    314
388    357    314
393    357    320
405    362    326
389    359    339
384    354    343
381    353    347
382    354    347
385    357    347
376    353    348
383    353    345
391    351    345
401    359    336
401    359    340
408    363    350
393    362    345
393    363    345
393    365    346
389    365    347
395    368    346
391    367    347
391    368    347
388    367    348
381    364    349
391    371    346
393    368    347
393    362    345
392    361    347
392    364    346

 

 

part 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 Atmega328?

1KB

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

Divide it by four!

YouTube plugin error

 

Comments (1)

Wendy Ju said

at 4:01 pm on May 25, 2011

Like the Kite flying application!

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