Lab 2: Frankenlight (Shane Leonard)


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

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

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

 

1. a. No changes are needed to make the LED blink, except that you must upload the existing code to the board.

    b. Change either or both of the "delay(1000)" lines to change the rate of blinking. The change will take the form of "delay(a)...delay(b)", where a is a number that controls the amount of time that the LED is on, and b is a number that controls the amount of time that the LED is off.

    c. Add a resistor to the circuit to protect the LED and board.

 

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

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.

 

2. a. You must change the second line from "const int ledPin = 13;" to "const int ledPin = 9;".

    b. The only code changes are switching the "digitalWrite(ledPin, HIGH)" and "digitalWrite(ledPin, LOW)"

  1. // set pin numbers:
  2. const int buttonPin = 2;     // the number of the pushbutton pin
  3. const int ledPin =  13;      // the number of the LED pin
  4.  
  5. // variables will change:
  6. int buttonState = 0;         // variable for reading the pushbutton status
  7.  
  8. void setup() {
  9.   // initialize the LED pin as an output:
  10.   pinMode(ledPin, OUTPUT);     
  11.   // initialize the pushbutton pin as an input:
  12.   pinMode(buttonPin, INPUT);     
  13. }
  14.  
  15. void loop(){
  16.   // read the state of the pushbutton value:
  17.   buttonState = digitalRead(buttonPin);
  18.  
  19.   // check if the pushbutton is pressed.
  20.   // if it is, the buttonState is HIGH:
  21.   if (buttonState == HIGH) {     
  22.     // turn LED on:   
  23.     digitalWrite(ledPin, LOW)
  24.   }
  25.   else {
  26.     // turn LED off:
  27.     digitalWrite(ledPin, HIGH);
  28.   }
  29. }

 

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

b) How would you change the rate of fading?

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?

 

3. a. If I use pin 9 for the LED, no changes are necessary to make the LED fade.

    b. There are several ways to change the rate of fading:

           1) In the "for" loops, change the increment from 5 to some other value (a lower value results in slower fading)

               The drawback of this approach is that the increment determines the "resolution" of the fade (ie the number of transitory fade states), and                so a faster fade will also be less "smooth."

           2) Change either or both of the "delay(30)" lines to "delay(some other value)" (a lower value results in faster fading)

               This approach maintains the smoothness/resolution of the fade, but if really small values are used in the delay, they can interfere with the                pulse width modulation used to emulate the analog signal.

 

Frankenlight

 

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

 

1. a. My circuit does not need an additional resistor, because the forward voltage drop on the LED (3.2 V) is greater than the voltage of the power source (3 V). Therefore, the internal resistance of the LED is sufficient to lower the current below 30 mA.

 

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

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

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?

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

 

2. Schematic:

 

2. a. NOTE: I am not sure whether the device is a camera or a projector. Therefore, I describe it as a camera (and as a projector in parentheses). The computation covers almost the entire top and bottom of the main chip. The computer is handling input (or output) from a PC, processing images (sending projections) from the camera (to the projector). The computer stores images, transfers them between the inputs and outputs, and translates them into readable or expressable data structures.

b. If the device is a camera, then the primary sensor is the lens, which streams data to the internal computer, which processes it and sends it to the PC. If it is a projector, then the primary "sensor" is the serial input ports, which "sense" data from the PC and translate it into projectable images.

c. The device has a backup battery (3 V), which maintains the memory storage in the device. However, it is primarily operated using an external AC power source.

d. The device stores images, as well as the data needed to interface with a PC, receive/execute commands, and display/collect images. The information is stored in several integrated circuits on the main circuit board.

 

Here is the link to my Frankenlight video:

http://www.youtube.com/watch?v=s55HGBO0y-E