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



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


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

The lines of code that connect the LED to the Arduino pin is in the void setup. The LED should be connected to pin 9 so the pinMode(13, OUTPUT) should be replaced with pinMode(9, OUTPUT). The lines that make the LED blink are the ones in the void loop. 

digitalWrite(13, HIGH); and delay(1000); make the LED turn on for one second. digitalWrite(13, LOW); and delay(1000); make the LED turn off for one second (1000 microseconds). Because it is in a loop, the LED will be turned on and off for one second each continuously until the program is terminated.


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

The lines of code that change the rate of the blinking are the delay(1000); lines. By changing the values, one could make it blink faster or slower and also change the blinking so that the LED is on for longer than it is off or longer when it is off compared to when it is on.


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

Circuit elements that would protect the board and LED include resistors and fuses.



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

The lines that would need to be modified are the lines of const int that are defined before the void setup and void loop. By changing what the variable buttonPin equals, you can reassign which pin on the Arduino the button corresponds with. The same could be done with the LED.


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;    

const int ledPin =  9;     


int buttonState = 0;         

void setup() {

  pinMode(ledPin, OUTPUT);

  pinMode(buttonPin, INPUT);



void loop() {

  buttonState = digitalRead(buttonPin);


  if (buttonState == HIGH) {

    digitalWrite(ledPin, LOW);


  else {

    digitalWrite(ledPin, HIGH);





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

The line of code that would have been modified would be  int ledPin=9, but because it is already set as pin 9, nothing needs to be modified.


b) How would you change the rate of fading?

One could change the rate of fading by changing the delay value in which one sees the dimming of the LED.


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?

One could change the fadeValue in order 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.) 


R= 106.67 ohms


5V= 0.03A*R

R= 166.67 ohms


The minimum resistor size that should be used is 166.67 ohms.

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

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






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

There is computation in the keyboard circuit in the black blob. I think that the keyboard matrix is set up like an array so that the resistance values from each combination of switches is processed through the black blob and then assigned a certain value that is then transferred to the another component of the computer through the USB cable.

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

The sensors are underneath the keys in the keyboard. When the keys are pressed a switch closes a circuit inside. In an array each key would have a different resistance value that would then be transferred over to the black blob. The black blob would then identify the resistance value as a value that we understand such as a letter, number, or command.

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 the USB cable. There is most likely power regulation through the black blob in resistance or the capacitors. The voltage used throughout the system is commonly 5 volts with a USB.

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

Information is stored within the memory of the circuit which is located in the black blob. The corresponding resistances from the array and the values that are outputted from the switches are stored there. The information is then transferred to a computer through the USB cable where it is reprocessed so that the computer can read the values and display them.







Comments (1)

zahraa@... said

at 2:04 pm on Jul 15, 2015


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