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

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.


Emily Huang - Lab 2 Report

Page history last edited by Emily Huang 6 years, 12 months ago


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

None. The codes in the example are already written to make the LED blink.

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

In the void loop, the delay is the milliseconds that the LED stays on or stays off, so by changing the numbers, the rate of blinking changes as well. The bigger the number is, the slower the rate is. 

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

A resistor. It resists the current in the circuit, so it wont go overboard.


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

In the line, const int ledPin =  13; change the number 13 to the LED pin that the LED is connected to, which is 9 in this case.

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.

In the original code, the LED lights when button us not pressed, to change it, the code, 

  if (buttonState == HIGH) {     

    // turn LED on:    

    digitalWrite(ledPin, HIGH);  


  else {

    // turn LED off:

    digitalWrite(ledPin, LOW); 


needs to be reversed. So it will be like this,

  if (buttonState == HIGH) {     

    // turn LED on:    

    digitalWrite(ledPin, LOW);  


  else {

    // turn LED off:

    digitalWrite(ledPin, HIGH); 



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

int ledPin = 9; change the number to the LED pin the LED is connected to.

b) How would you change the rate of fading?

Change the value of fadeValue +=5 and fadeValue -=5 in the void loop. When the value is higher, the fading rate is faster. Vice Versa.

c) (Extra) 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?

The fadeValue must increase/decrease exponentially in order to make the light appear to fade linearly. For example, this can be done by changing the fadeValue +=5statement to fadeValue *=2 so that fadeValue increases exponentially.


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.) 

Voltage of power source: 5 V

Voltage of LED: 3.2 V

Current: 30 mA= 0.03 A

Voltage of resistor: 1.8 V (Vpower-VLED)


Ohm's law: V=RI,  which equals to R=V/I, therefore R= 1.8/0.03= 60 Ω

The resistance to limit current is 60 Ω


a. Is there computation in your device? Where is it? What do you think is happening inside the "computer?"

the computer sends signals to the hard drive, and stores data there.

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

no, I don't think there's any.

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?

There is a power cable connecting to the hard drive from the computer, and the voltage of it, I believe, is 5 v.

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

Yes,  it is stored on the hard disk in the form of 0 and 1, and it is stored on the circular disk.





Comments (2)

Vivien Tsao said

at 12:11 am on Jul 15, 2013

-3... Where is your Frankenlight? :( + video?

Vivien Tsao said

at 12:11 am on Jul 29, 2013

+3 for vid + frankenlight

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