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

Stritter Sienna Lab 2

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

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

     The sample code automatically blinks the onboard LED, which is attached to pin 13. If you wanted to blink an LED connected to a different pin, you would need to change line 20 (pinMode(13, OUTPUT);), line 25 (digitalWrite(13, HIGH);), and line 27 (digitalWrite(13, LOW);) so that instead of referring to pin 13, you would be controlling whatever pin you connected the LED to.

 

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

     Lines 26 and 28: delay(1000);

     By changing the parameter to the delay function, we can control how long the program waits before changing the state of the LED. This gives us control over the rate of blinking.

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

     We want to add a resistor.

 

 

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

     The instructions tell us to build a circuit with the LED on pin 9 and a button on pin 2. In the code, line 29 (const int buttonPin = 2;) sets the button pin to 2 but line 30 (const int ledPin =  13;) sets the LED pin to 13. We need to change line 30 to const int ledPin =  9;.

2b. 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.

     The way I had my circuit built, I did not need to modify the code besides changing the LED pin number. If you held down the button, the LED would light. When you released the button, the LED went off.

 

 

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

  }

}

 

 

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

     I put my LED on pin 12, so I needed to change line 21 from int ledPin = 9;  to int ledPin = 12;.

3b. How would you change the rate of fading?

     To change the rate of fading we must change line 33 and line 41, delay(30);. These lines control how long it waits before changing to the next fade value. If we made the parameter to the delay function greater than 30, the LED would fade more slowly. If we made the parameter to the delay function less than 30, the LED would fade more quickly.

 

 

 

Part C. Frankenlight 

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

     I used a keyboard powered by two 1.5V batteries in parallel. Since 1.5V is below the forward voltage of the superbright LED, 3.2V, my device will be unable to light the superbright LED. 

     Assuming we had a 5V power source, though:

          V = I * R

          R = V / I 

          V = 5V - 3.2V = 1.8V

          I = 0.03 A

          R = 1.8V / 0.03 A = 60 Ω

COOL 

 

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

     There are two little black chips on the PCB connected to all the electrical traces under the keys. When a key is pressed, a broken circuit becomes closed and an electrical signal can travel to these chips. They process the signal to determine what key has been pressed, and somehow use radio to wirelessly convey this information to your actual computer so it knows which key has been pressed.

 

 

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

     There are many keys on the keyboard. Inside the keyboard, there are three layers of plastic. The top and bottom layers have electrical contact points and traces. The middle layer simply has holes where each key is so that when you press down on the key, the top layer and the bottom layer are pressed together and the electrical contact points touch. This completes a circuit, so the electrical signal can be conveyed to the chips on the PCB. The mouse click buttons work the same way as the keys.

 

 

2c. 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 keyboard is powered by two 1.5V batteries. Using the multimeter, I determined that they are wired in parallel. I'm not sure if there is transformation or regulation of the power - as far as I can tell, the voltage remains 1.5V throughout the system.

 

 

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

     I think some information must be stored within the computation chips on the PCB of the keyboard. It must keep track of which electrical signal corresponds to each key being pressed. It also must store which key or button has been pressed so that it can communcate that information to the computer the keyboard is linked to.

 

 

3. Schematic

 

 

4. Video

 

 

Comments (1)

zahraa@... said

at 3:29 pm on Jul 15, 2015

GREAT JOB

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