Yuhui (Alexander) Li Lab 2


B

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

  digitalWrite(led,HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led,LOW);    // turn the LED off by making the voltage LOW
  delay(1000);

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

     delay(x);  x stands for the milliseconds between light on and off.

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

     Resistor

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

     Modify the const int value to 9, which is where the LED is connected to.

2b. 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.

     Modify the if statement here to make the LED on when buttonState is LOW, which is off.

     if (buttonState == LOW) {     

         // turn LED on:    

         digitalWrite(ledPin, HIGH);  

     } 

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

     ledPin variable. The default is 9 so if the LED is already connected to 9, nothing has to be changed.

3b) How would you change the rate of fading?

     Change the delay(x) value to either increase or decrease the rate of fading. The larger x is, the slower the fading is.     

3c) (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 default increment or decrement in for loop is 5, making this value lower would make the light appear to fade more linearly.

 

 

C

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

     I'm supplying 5V to the circuit and the forward voltage drop of the LED (3.2V) makes the total voltage 1.8V. To limit the current to 30mA, use 1.8/0.03=60 Ohm resistor. Or to limit the current to 20mA, use 1.8/0.02=90 Ohm resistor.

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

     There is computation in the old laptop I dissembled. It is the central processing unit (CPU) on the motherboard. It is protected by a BIG THICK metal board and because the screws were so tight that I wasn't able to take a closer look at it or take it off. The CPU calculates everything. It receives command (input) from all parts of the computer including keyboard, mouse, buttons, and sends out commands (output) to parts such as screen, speaker.

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

     There are buttons (including keyboard+trackpad) on the outside as well as few smaller ones directly on the motherboard. The motherboard also has a potentiometer which controls the volume of the speaker. It is a pretty old laptop so it doesn't have fancy sensors such as light sensor, fingerprint reader, etc. The sensed information is sent via wires on the printed circuit board to the CPU.

2c. 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 device uses DC power which could be drawn from the battery or from the AC adaptor. I assume the battery is a kind of transformation of power? And the AC to DC adaptor is external and I didn't get the power cord so I can't investigate it. 

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

     Yes, the information could be stored in the hard drive (which was taken out probably it was usable but the computer wasn't) for permanent (unless the hard drive breaks down and it does) storage. It also has a 125MB memory installed for quick and temporary storage.