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

  • Get control of your email attachments. Connect all your Gmail accounts and in less than 2 minutes, Dokkio will automatically organize your file attachments. You can also connect Dokkio to Drive, Dropbox, and Slack. Sign up for free.

View
 

Lab 2 writeup

Page history last edited by Huda 7 years, 11 months ago

Graded by Huda - Check

Part B

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

        The int led = 13; line. The 13 is changed to a 11 because that is where our pin is attached.

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

            The delay lines need to be changed; the time between each pause.

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

            I would add a resistor to lower the voltage and make sure the LED does not blow up.

 

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

    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.

The second line (const int ledPin=13) needs to be changed. The 13 is replaced by 15.

// 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 =  15;      // the number of the LED pin

  // Pin 13: Arduino has an LED connected on pin 13

  // Pin 11: Teensy 2.0 has the LED on pin 11

  // Pin 6: Teensy++ 2.0 has the LED on pin 6

// 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)  a) Which line(s) of code do you need to modify to correspond with your LED pin?

The int ledPin=13; line. The 13 is replaced by  a 9.

b) How would you change the rate of fading?

You change the value of 5 in the line fadeValue +=5. To increase the rate, you type in a bigger number. To decrease the rate, you use a smaller number.

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?

In the line fadeValue+=5, you can change the value of 5 for a number in exponential form so the  rate would have a greater increase in rate as times passes by.  

Part C (Mouse)

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

V=IR -> R=V/I           R=1.85v/0.03A=60 Ohms

V=5v

Vf=3.2v

Vtotal= 5v-3.2v+1.8v

I=30mA=0.03A

 

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

            The sensor (light sensor) sends signals to the computer.

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

            The mouse has a light sensor. When the light sense a platform, the mouse send signslas to the computer which allows the cursor to move a corresponding amount.  

 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 mouse is powered by the computer through a USB cable. The mouse has two button switches, which break the voltage connection when pressed. The mouse runs under approximately 5v.

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

            No, the mouse does not store inforamtion. Some information is actually stored in the mouse processor to make it work properly. Try googling it to find out more.

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

http://youtu.be/rditUgalbjY - the inside of the mouse

http://youtu.be/qpMBz6x8LHs- the LED in the mouse

 

Comments (1)

Benjamin Tee said

at 2:29 am on Jul 22, 2012

Nice job!

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