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


Lab Report 2: EE47

Page history last edited by Benjamin Tee 8 years, 2 months ago

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

The line :

            int led = 13;

Needs to be changed to :

            int led = 11;

To correspond to the location of the LED onboard the Teensy. Without this modification, the LED onboard the Teensy won’t blink.


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

The arguments to the line :


Can be changed to either a value greater than 1000 or less than 1000 to decrease or increase the rate of blinking respectively.

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

A resistor should be added to the circuit to protect both the board and the LED.

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

The line :

const int ledpin = 13;

Needs to be changed to :

            const int ledpin = 9;

To correspond to the placement of the LED. The line for the placement of the button does not need to be fixed.

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.




 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.





// 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 =  9;      // the number of the LED pin

  // Pin 13: Arduino has an LED connected on pin 13

  // Pin 11: Teensy 2.0 has the LED on pin 11

  // Pin 6: Teensy++ 2.0 has the LED on pin 6


// 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 on:   

    digitalWrite(ledPin, HIGH); 


  else {

    // turn LED off:

    digitalWrite(ledPin, LOW);




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

No modifications were required as the line :

int ledPin = 9;

Already referred to the correct location of the LED pin.

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

In the lines :


for(int fadeValue = 0 ; fadeValue <= 255 ; fadeValue +=5)




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

We can see that the program tells the LED to increase/decrease it’s brightness by 5 points each time. By increasing or decreasing the rate of change of values, we can increase or decrease the rate of fading respectively.


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?

To make the light appear to fade linearly, the brightness of the light must be made to change exponentially. For example, the lines :


for(int fadeValue = 0 ; fadeValue <= 255 ; fadeValue +=5)




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


Can be changed to :


for(int fadeValue = 0 ; fadeValue <= 255 ; fadeValue *=4)




for(int fadeValue = 255 ; fadeValue >= 0 ; fadeValue /=4)

To make the light appear to fade linearly.


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

We know :

VBattery = 5 V

VDrop,LED = 3.2 V

Imax = 30mA = 0.03 Amps


From Kirchhoff’s Law;

VTotal = V1 + V2 + … Vn



5 V = 3.2V + Vx

Vx = 5 V – 3.2 V = 1.8 V


Using Ohm’s Law;

V = IR



1.8 V = 0.03 A • R

R = 1.8 V / 0.03 A = 60 Ω

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

Yes, there is computation. The motherboard (device that I took apart) is the “heart” of the computer, in the sense that all the computation occurs inside of it. It consists of primary and secondary memory. The primary memory is where all computational processes occur. The secondary memory is where all the information and computation is stored.

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

Yes, there are two push buttons that perform some electrical or mechanical operation on the motherboard, such as allowing current to flow to the primary or secondary memory, or activating certain parts of the motherboard. By pushing down on the button, two metal contact pins inside the switch connect and allow current to flow through, while two other metal contact pins disconnect simultaneously. As a result, current flow can be easily controlled. The altered flow of current can instruct the motherboard to perform some operation.


5c. 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 power is supplied via a power cable connected to an electrical wall socket. The AC voltage from the wall socket is converted into lower voltage DC current. 5 Volts of electricity are used throughout the system

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

Information is stored either in the primary memory or the secondary memory. The primary memory is the place where programs are booted to and where all the computation occurs. This could be done through the transistors present inside the primary memory, which store either a HIGH state or a LOW state. The secondary memory is where all the computational data is stored for later recall. The secondary memory is presumably magnetic, as there is a hard disk attached to it (had to be removed for the sake of portability).



         = Duncan Abbot: Grader

         = Grade I received = Check

         = Grade I gave = Check.


My Frankenlight: http://www.youtube.com/watch?v=o4xvYkFmcZQ


Comments (1)

Benjamin Tee said

at 3:09 am on Jul 22, 2012

Great job! Good video and explanation of what you did.

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