• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.


Johansson Theodor Lab 2

Page history last edited by zahraa@... 5 years ago Saved with comment

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

     There are four line of code in the Blink program that cause the LED to blink: 

          digitalWrite(13, HIGH);


          digitalWrite(13, LOW);



     What these lines do is (in order):

          1. Turn the LED on

          2. Wait one second

          3. Turn the LED off

          4. Wait one second

     Because these lines are inside the update() loop, they are executed repeatedly and indefinitely.

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

     To change the rate of blinking, simply modify the numbers in the delay() functions.

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

     To protect the board and LED, a resistor could be added to the circuit. This would likely reduce the total voltage of the circuit, hopefully into the LED's      tolerable voltage range.

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

     Any line of code that contains buttonPin interacts with pin 2 (which is hooked up to the button). Any line that contains ledPin interacts with pin 13,      which is the output 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.





 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 =  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:


  // In the original code, the check in the if statement turned on the LED if the buttonState variable was high.

  // The following line of code was all that needed to be changed to activate the LED when the button is depressed.

  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?

     All lines (or blocks) of code that contain the ledPin variable correspond to the LED pin.

b) How would you change the rate of fading?

     The rate of fading can be changed by modifying the number inside the delay() functions.

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?


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

     3.2 = .03 * R

     R = 3.2/.03

     R = 110 Ohms

     The minimum resistor size that should be used is 110 Ohms.

It is partially correct, but the complete correct answer is :

R = (Vcc - Vf) / If = (5V – 3.2V) / 20mA = 90 Ohms. (-0.2)


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

     There is definitely computation in this device. It occurs in the microchips in the breadboard, and is sent out via the chord that must be connected to      a computer. Inside the computer, the data is read by laser from the floppy disk and then interpreted by the microprocessors.

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

     On my device, there is a laser that reads the floppy disk. This laser sends information directly to other parts 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?

     The device is powered by the computer to which it is connected via the chord that connects the device to the computer. The voltage was not written      on the device, but the voltage it is supplied is most likely five volts, as that should be sufficient to run the device.

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

     Information must be stored on the device, because the device reads data from an input, processes it, and sends it to a computer. This storage must      be near the microprocessors to allow easy access.

Fliqz has shut down their service. To access this video, email support with this video id: 125c8d6ff7914fac849c2a6588249f8b

Comments (1)

zahraa@... said

at 1:54 pm on Jul 15, 2015

great job

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