• 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, 2 months ago

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

void loop() {

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);               // wait for a second

  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);               // wait for a second


This loop makes the LED blink by alternating voltage and giving a delay of one second.


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


By changing the "1000" to some other number, the time the LED "waits" can be changed. This changes the time the LED is on and the time the LED is off, which changes the rate.


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

I would want to add a resistor to monitor the current. I would use a 150 ohm resistor just to be safe.


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

const int buttonPin = 2;     // the number of the pushbutton pin

const int ledPin =  13;      // the number of the LED pin

I would have to change the integers (2 and 13) to the ones that correspond with the pins the components are connected to.


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.

  if (buttonState == LOW) {

    // turn LED on:

    digitalWrite(ledPin, HIGH);


  else {

    // turn LED off:

    digitalWrite(ledPin, LOW);


By changing the if statement's condition, the program now keeps the LED on until the button is pressed.


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

int led = 9;     

I would have to change the integer to the one corresponding to the LED pin.


b) How would you change the rate of fading?

int fadeAmount = 5;   

I would have to change the fadeAmount variable into some other integer to change the rate of fading. The lower the fadeAmount, the less the LED fades and vice versa.


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




R=60 ohms

My device is a Pedometer.


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

Every time the switch completes the circuit, the counter increases by 1 and is displayed on the LCD display. The button resets the counter. The computer should be inside the black blob on the PCB and is responsible for counting the number of times the switch is connected.

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

The sensor is mostly mechanical;when the pedometer shakes, the circuit is completed for an instant, which increases the counter by 1 and counts as a "step." Because the completion of the circuit is seen as a "step", the information that the circuit has been completed goes to the board to the LCD where the number displayed increases by 1.

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 button cell battery. The power is probably regulated for the LCD display using resistors soldered onto the PCB since the current changes. The voltage that the battery provides is 1.5 volts.

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

The information stored is the number of steps taken, with each step being each time the circuit is completed. This number is stored on the board and can be reset with a push of a button. 

Here is the video of the LED. The battery was replaced with the microcontroller because 1.5 volts is not enough to power the LED:







Comments (1)

zahraa@... said

at 3:17 pm on Jul 15, 2015

great job

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