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

View
 

Lab_2

Page history last edited by Benjamin Tee 8 years, 3 months ago

Lab 2: Frankenlight

Teensy LED & Frankenlight

 

Part B. Teensy LED!

1. Blinking LEDs with the Teensy

 

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

 

I need to change line 12.

int led = 11;

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

 

I need to change lines 23 and 25.

 delay(1000);

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

 

I need a series resistor, since voltage drop on LED can’t vary in a big range, and some voltage drop should happen on the resistor.

2. Toggle LEDs on and off using the Teensy

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

 

I need to change line 30

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.

 

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

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

 

int buttonState = 0;         // variable for reading the pushbutton status

 

void setup() {

  pinMode(ledPin, OUTPUT);     

  pinMode(buttonPin, INPUT);    

}

 

void loop(){

  buttonState = digitalRead(buttonPin);

 

  if (buttonState == HIGH) {    

    digitalWrite(ledPin, HIGH); 

  }

  else {

    digitalWrite(ledPin, LOW);

  }

}

3. Fading LEDs on and off using the Teensy 

 

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

none

b) How would you change the rate of fading?

By modifying the delay steps.


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?

We can apply the exponential steps of voltage.

Not quite, but good try.

 

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

R > (Vbat – Vf)/Imax = (5-3.2)/0.03 = 60 Ω.

 

Rmin = 60 Ω.

 

R = 62 Ω

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

I had a standard 110 key qwerty keyboard. It has a microcontroller located on the circuit board with some other circuit elements. The microcontroller processes the signals from the keyboard keys, sends the signal to the PC motherboard through the USB connection. Also it sends the signals to 3 LEDs on the keyboard that light up, when one of Caps, Scroll or Num Locks is on.

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 key matrix in the keyboard - a grid of circuits underneath the keys. The circuit is broken at a point below each key. When you press a key, it presses a switch, completing the circuit and allowing current to flow through. If you press and hold a key, the processor recognizes it as the equivalent of pressing a key repeatedly.

 

When the processor finds a circuit that is closed, it compares the location of that circuit on the key matrix to the character map in its memory.

 

The keyboard uses mechanical switches for its keys. Under the keys there is a membrane along the whole keyboard with rubber domes for each key. Due to elasticity of the rubber domes the pressed key is brought back up when it's released. Under the membrane there are two layers of plastic sheets with embedded circuitry. Both the layers are separated by third - a thin plastic layer. When we press a key on the keyboard, it pushes down the dome shaped rubber button which in turn electrically connects the top & bottom layer at that point and the signal is sent to the keyboard microprocessor. It processes the signal and sends it to the computer through USB.

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 from USB, 5 V DC. There may be some transformation and regulation of the power in the keyboard microprocessor.

d. Is information stored in your device? Where? How?
The sensed information is not stored in the device, but rather directly sent by USB to the PC. However the ROM is present, by which the pressed keys are recognized.

 

4. Build your light!

  

Please post a short video of your frankenlight to your lab report page. Include any schematics as well.

I hooked up to the keyboard LED that lights up when the Scroll lock is on. The red LED is connected to a series resistor and Scroll lock LED. So when Scroll lock button is on both LED light up. 

 

Comments (1)

Benjamin Tee said

at 1:50 pm on Jul 21, 2012

Good job David!

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