Lab 2: Frankenlight Write Up


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

I need these lines to make the LED blink:

 

void loop() {

     digitalWrite(led, HIGH);

     delay(100);

     digitalWrite(led, LOW);

     delay(1000);   

}

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

I need to change parameter in the delay() function to change the rate of the blinking

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

I would want to add resistors.

-----------------------------------------------------------------------------------------------------

 

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

I need to modify these lines' numbers:

 

const int buttonPin = 2;     // the number of the pushbutton pin

const int ledPin =  13;      // the number of the LED pin

 

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.

/*

  Button

 

 Turns on and off a light emitting diode(LED) connected to digital  

 pin 13, when pressing a pushbutton attached to pin 2. 

 

 

 The circuit:

 * LED attached from pin 13 to ground 

 * pushbutton attached to pin 2 from +5V

 * 10K resistor attached to pin 2 from ground

 

 * Note: on most Arduinos there is already an LED on the board

 attached to pin 13.

 

 

 created 2005

 by DojoDave <http://www.0j0.org>

 modified 30 Aug 2011

 by Tom Igoe

 

 This example code is in the public domain.

 

 http://www.arduino.cc/en/Tutorial/Button

 */

 

// constants won't change. They're used here to 

// set pin numbers:

const int buttonPin = 2;     // the number of the pushbutton pin

const int ledPin =  13;      // the number of the LED pin

 

// variables will change:

int buttonState = 0;         // variable for reading the pushbutton status

 

void setup() {

  // initialize the LED pin as an output:

  pinMode(ledPin, OUTPUT);      

  // initialize the pushbutton pin as an input:

  pinMode(buttonPin, INPUT);     

}

 

void loop(){

  // read the state of the pushbutton value:

  buttonState = digitalRead(buttonPin);

 

  // check if the pushbutton is pressed.

  // if it is, the buttonState is LOW:

  if (buttonState == LOW) {     

    // turn LED on:    

    digitalWrite(ledPin, HIGH);  

  } 

  else {

    // turn LED off:

    digitalWrite(ledPin, LOW); 

  }

}

 

-------------------------------------------------------------------------------------------

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

I would change this line of code:

int ledPin = 9;

b) How would you change the rate of fading?

I would change the rate of fading by altering this:

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {

 

to this:

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=15) {

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?

I could change the "delay(30)" line of code in the fading for loop to "delay(100)".

----------------------------------------------------------------------------------------------

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

The minimum resistor size can be found using Ohm's Law:

V = IR

If I supply 5 volts to the circuit, then my minimum resistance would be:

R = (5-3.2) Volts/ 0.03 Amps

R = 60 ohms

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?

No, there aren't any sensors on the device, although there are a few USB and VGA ports on it.

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 device is powered through a port that intakes DC electricity from an adapter.

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

Information is stored in the hard drive (which isn't on this circuit board) using a disc that is rotated and etched on. There are also some RAM ports, but there's no RAM in them.

--------------------------------------------------------------------------------------------------