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

  • Social distancing? Try a better way to work remotely on your online files. Dokkio, a new product from PBworks, can help your team find, organize, and collaborate on your Drive, Gmail, Dropbox, Box, and Slack files. Sign up for free.

View
 

(Ray) Lab 2: Frankenlight

Page history last edited by Ray Zhou 7 years, 1 month ago

Part B: Arduino micro LED!

 

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

 

          To make the LED blink, change the following line...

               int led = 13;

          ... into this line:

               int led = 9;

          This is because we are using pin 9 instead of pin 13.

 

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

 

          To make the LED blink faster, input a smaller number into the 2 calls to the delay function within the loop function, such as 500:

 

               delay(500);

 

          To make the LED blink slower, input a larger number into the 2 calls to the delay function within the loop function, such as 2000:

 

               delay(2000);

 

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

 

          You would want to add a resistor to protect the board and LED (by limiting the current in the circuit board).

 

2. Toggle LEDs on and off using Arduino Micro2.

  

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

 

          To correspond with the button and LED pins, change the following line...

               int ledPin = 13;

          ... into this line:

               int ledPin = 9;

          This is because we are using pin 9 instead of pin 13.

 

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.

 

          In the loop function, swap the following two lines:

 

               digitalWrite(ledPin, LOW);

               digitalWrite(ledPin, HIGH);

 

          The loop function is now as follows:

 

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

               digitalWrite(ledPin, LOW);  

          } 

          else {

               // turn LED on:

               digitalWrite(ledPin, HIGH); 

          }

     }

     

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?

 

No modifications are necessary, since the sample code already uses pin 9 (which our circuit is using as well).

 

b. How would you change the rate of fading?

 

Change the rate at which fadeValue changes in the 2 for loops within the loop function. The original lines of code are as follows:

 

     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {

     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue -=5) {

 

The rates above are += 5 and -=5. We can change these values to, say, +=50 and -=50, respectively:

 

     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=50) {

     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue -=50) {

 

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?

 

Add your response here.

 

Part C: Frankenlight!

 

1. Super Bright LEDs

 

a. What is the minimum resistor size that should be used with these LEDs?

 

R = (5V - 1.8V) / (30mA) = 60 Ohms

 

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

 

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

 

          There is no computation in my device, as far as I can tell. 

 

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

 

My device uses USB as its sensor. The circuit board receives input from a USB cable, which can be plugged into a computer or other device. This information is conveyed via wires, resistors, and capacitors across the rest of the circuit board. Other components of the circuit board include LEDs and an oscillator.

 

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?

 

My device is powered by its USB input. As far as I can tell, there is no transformation of power (since the circuit board contains no transformers). Regulation of the power is done via resistors and capacitors.

 

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

 

          No information is stored in my device, as far as I can tell.

 

At first, I was perplexed as to what my device was. The device had 3 LEDs and took in USB as its input. I wondered what would happen if I plugged it into a computer, so I powered up one of the lab computers and simply plugged the device in. To my surprise, one of the 3 LEDs actually lit up. Looking at the 3 LEDs more closely, I saw that each LED had a description. The 3 descriptions are as follows:

 

     "D1 Num"

     "D2 Caps"

     "D3 Scr"

 

The D1 LED had lit up. I realized at this point that the 3 descriptions probably stood for Num lock, Caps lock, and Screen lock, respectively. I tested this by pressing the Num lock button on the lab computer's keyboard. The LED turned off, as expected. I proceeded to test the Caps lock and Screen lock on the keyboard; each toggled its appropriate LED as expected.

 

I didn't expect the device to still be functional and compatible with the lab computers, so that was a cool surprise. Anyhow, this is how I ended up identifying my device.

 

Add your schematic here.

 

3. Using your schematic, figure out where a good point would be to hijack your device and implant an LED.

 

4. Build your light!

 

 Add your recording here. 

Comments (0)

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