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


Nick's Lab 2 Report

Page history last edited by Vivien Tsao 7 years, 2 months ago

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


None of the lines of code need to be changed in order for the LED to blink.

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


In order to change the rate of blinking, you must change the lines of code with "delay(1000);" because the delay function dictates how long the LED stays either on or off before switching back to the other mode.

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


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

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


I need to modify the line "const int led = 13" to say "const int led = 9" because my LED is connected to pin 9. My button is connected to pin 2 so no other lines need to be modified.


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


None of the lines of code have to be modified to correspond with the LED pin.

b) How would you change the rate of fading?


In order to change the rate of fading, I could either change the rate at which fadeValue increases/decreases in the for loop, or I could change the value in the delay() function to make it wait longer or shorter before changing the brightness of the LED.

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 Arduino gives a supply of 5V, and the superbright LED has a voltage drop of 3.2V, so there will be 1.8V going across the resistor. The maximum current across the LED is 30 mA, so the minimum resistor size to be used is 60 Ohms ( (5V - 3.2V) / .03 A = 60 Ohms).

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


There is no computation inside my device.

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


There is a sensor on my device. When the protruding button is pushed, it closes the circuit inside, and when it is pushed a second time, it opens the circuit.

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 using a 5V power supply. The power is regulated using a resistor. There is a 1.85V drop across the red LED, so 3.15V are going across the circuit.

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


No information is stored in my device, as there is no data storage device inside.

Comments (1)

Vivien Tsao said

at 12:57 am on Jul 15, 2013

Good job! Can you please upload your video files on youtube next time? Thanks!

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