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

Yang Jeffery Lab 2

Page history last edited by zahraa@... 5 years, 2 months ago

1.

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

you don't have to change the code; the led is already blinking

 

 

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

change the parameters in the delay lines of code

 

 

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

a resistor

 

2.

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

change ledPin from 13 to 9

buttonPin was already at 2

 

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.

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  9;      // 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 HIGH:
  if (buttonState == HIGH) {     
    // turn LED off:    
    digitalWrite(ledPin, LOW);  
  } 
  else {
    // turn LED on:
    digitalWrite(ledPin, HIGH); 
  }
}

 

3.

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

None because ledPin was already set to 9

 

 

b) How would you change the rate of fading?

change the delay parameter

 

 

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?

increase the delay value

 

Part C

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

R=V/I

R=(5V-3.2V)/0.03 A

R=60 ohms

60 ohm resistor

2.

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

Yes; examples include the CPU and GPU. Inside the computer, electricity flows through a complicated circuit with many resistors, computer chips, and capacitors.

 

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

No

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 by a battery in the computer. Power is regulated through resistors and capacitors. 

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

Information is stored on the hard drive and RAM. On a hard drive, bits of data are stored on circular tracks, and each track is broken up into sectors. As a result, a multitude of information can be stored on a hard drive. 

4. Frankenlight and schematics 

https://www.youtube.com/watch?v=bk1KCOFv3_Q

 

 

 

Comments (1)

zahraa@... said

at 4:04 pm on Jul 15, 2015

good job

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