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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Kimbrough Jerome Lab 2

Page history last edited by zahraa@... 8 years, 9 months ago

 

Lab 2:

 

1. Blinking LEDs with Arduino Micro

 

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

The program as it is does not need to be modified for the LED to start blinking.

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

The rate of the blinking is controled by the delay function. The parameter it receives is the number of miliseconds to wait. So the programer can both control the HIGH and LOW time by changing the numbers in the delay function.

For example: 

  digitalWrite(13, HIGH);

  delay(1500);

  digitalWrite(13, LOW);

  delay(500);

→ this code will have the LED lit for 1.5 sec and turned off for 0.5 sec.

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

Adding a resistor to the circuit providing power to the board and to the LED would help protect them.

2. Toggle LEDs on and off using Arduino Micro

 

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

Because we use the same circuit as before, the ledPin is 9 and not 13. So the only line that needs to be changed is const intledPin =  13; to const int ledPin =  9; 

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.

 

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

 

// 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);

  }

}

3. Fading LEDs on and off using Arduino Micro 

 

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

As we are using the pin 9, we do not have to change the code. However, if that was not the case, the line of code which selects the pin is:

     int led = 9;  

which is used in line:

    pinMode(led, OUTPUT);

b) How would you change the rate of fading?

The rate of fading can be changed by changing the fadeAmount. A greater value of fadeAmount will make the fading faster.

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?

 

 

Part C. Frankenlight

 

1. Super bright LEDs

 

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

 

Using the same notations as in the picture LED_circuit.jpg, we have:

               VPower = VResistor + VLED and, using Ohm's Law, VResistor = R*i

So,

               R =  (VPower - VLED) / i

So,

               R = (5 - 3.2) / 0.03

          ie  R = 60 Ohm

 

Cool

 

2. Take apart your electronic device, and draw a schematic of what is inside.

 

I chose to take apart a remote control.

 

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

 

There is a central chip, but I am not sure if it actually computes anything. It might be programmed only to have an output corresponding to the input it gets (ie. sending a specific signal to the IR-LED according to the button you press on).

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

 

The only sensors present are the buttons of the remote. They act like simple switches, and they sent the information directly to the chip, which, in turn, sends the right information to the IR-LED.

 

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?

 

This specific remote control is powered by two AA batteries connected in series, which totals up to a 3V power supply. There does not seem to be any power regulation system in this device; the main voltage seems to be 3V, but there are two resistors on the main board, so some components might operate at lower voltages.

 

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

 

The information stored on the device concerns the signals which need to be sent. It is stored in the chip. No other information is stored. 

4. Build your light!

For this part, I chose to hack the IR-LED, because hacking any other component of the device would have rendered it unutilisable by others. This is the video I recorded of the hacked LED where I replaced the IR-LED with a red LED. I did not use the super bright LED because it needed more power than what got to the IR-LED and would not light up.

 

 

 

 

Comments (1)

zahraa@... said

at 2:00 pm on Jul 15, 2015

GREAT JOB

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