| 
  • 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
 

Lab Report 2 - Flavio Castro

Page history last edited by castro.flaviojr@... 7 years, 3 months ago

a. What line(s) of code do you need to change to make the LED blink (like, at all)?

The following lines make the LED blink:

     digitalWrite(led, HIGH);

     digitalWrite(led, LOW);

In this case you don't actually have to change any line to make the code LED blink.

 

b. What line(s) of code do you need to change to change the rate of blinking?

delay(1000); This function make the arduino waits 1000 ms before turning the LED off, if you decrease this time you will decrease the total blinking frequency.

 

c. What circuit element would you want to add to protect the board and LED?

A resistor.

 

Part 2

a. Which lines do you need to modify to correspond with your button and LED pins? 

You need to change the following lines:

const int buttonPin = 2;

const int LedPin=13;

buttonPin =2 defines we are using Pin 2 for the button, we don't have to change it. LedPin=13 defines we are using Pin 13 for the LED. SO, if we write const int LedPin=9; we will be all set.

 

b. Modify the code or the circuit so that the LED lights only while the button is depressed. Include your code in your lab write-up.

The only thing you have to do is to invert the actions taken given the pressing of the button which is defined by the condition: if(buttonState=HIGH)...

The new code is:

if(buttonState=HIGH){

     digitalWrite(ledPin,LOW);

}

else {

     digitalWrite(ledPin,HIGH);

}

 

Part 3

a) Which line(s) of code do you need to modify to correspond with your LED pin?

int ledPin = 9;

We just indicate we are using pin 9.

b) How would you change the rate of fading?

We have two ways: we can decrease the delay(30) function what would make the the system iterates faster, and we also can increase the fadeValue increment what would make the system go faster through the iterations of fadeValue from 0 to 255.

c)Since the human eye doesn't see increases in brightness linearly and the diode brightness is also nonlinear with voltage, how could you change the code to make the light appear to fade linearly?

First, I had two option: or increasing the delay - supposing we are sensible to frequency - or increasing the fadeValue - supposing we are sensible to intensity, i.e. we can't perceive subtle changes. So I tested and it turns out that none of them works alone. The answer for the question is both, if we only change the frequency, we can't perceive the changes because they are very subtle, on the other side if we only increase the fadeValue we can't perceive the changes because they are too fast. if we change both then we can see it. For example make a delay(100) and the increment be fadeValue=+25;

 

PartC

1. a. What is the minimum resistor size that should be used with these LEDs? (Hint: think about your voltage supply and what the diode voltage drop means.) 

V- Vf=RI, V = the power source=5 Vf= voltage drop is approx. 3.2V and the current is 3*10^-2A.

We can easily find that R = 60 Ohms.
2. a. Is there computation in your device? Where is it? What do you think is happening inside the "computer?" 

I found a little hard to open the devices and put my LED, so I basically took a switch of a circuit and attached it to my breadbord, so there's no computation.

b. Are there sensors on your device? How do they work? How is the sensed information conveyed to other portions of the device?

Yeah there's a sensor: the button.

c. How is the device powered? Is there any transformation or regulation of the power? How is that done? What voltages are used throughout the system?

The only power transformation happens on the arduino.

d. Is information stored in your device? Where? How?

There's no information stored in the device.

4. http://www.youtube.com/watch?v=86DVW0m4rtE

Comments (2)

Vivien Tsao said

at 12:13 am on Jul 15, 2013

? No type up?

Vivien Tsao said

at 12:21 am on Jul 29, 2013

+ 10 for type up.

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