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

Kellen Asercion Lab 2 writeup

Page history last edited by asercion@stanford.edu 10 years, 11 months ago

Part B)

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

 

All of the code is necessary to make the LED blink.  Changing the output pin, the code that turns it on/off (HIGH/LOW), or the pauses would cause the LED to not blink. 

 

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

 

By changing the delays between turning the LED on or off, you can change the rate of blinking.

 

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

 

A resistor would be needed to protect both the board and LED.

 

 

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

 

We need to set the output pin to 9 not 13.  

 

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.

 

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

  } 

  else {

    // turn LED off:

    digitalWrite(ledPin, HIGH); 

  }

}

 

 

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

 

We would need to make sure the output pin is set to pin 9.

 

b) How would you change the rate of fading?

 

By changing the fade value, you can make the LED fade faster or slower

 

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?

 

Write a function that changes the fade value in a nonlinear fashion as a function of time.

 

 

Part C)

 

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

 

We want a minimum resistance of (5V - 3.2V)/30mA or 60 Ohms.

 

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

 

There is an 18 pin processor in my device.  I looked up the data sheet from the serial number which says it is a "Pulse/Tone Dialer" and is used in telephones.  

 

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

 

The second chip in the device has 15 circular pads on it.  Initially, I wasn't sure what they were for, but realizing this component comes from a telephone it is now obvious that these pads correspond to the buttons on  a telephone dial pad.  The buttons are connected directly back to the processor, which makes sense.

 

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?

 

There are a few red/black pairs of wires coming off the main chip, which probably supply power.  The data sheet for the processor gives its voltage range to be between 2 and 5.5 volts, which is likely the voltage range of the whole system.

 

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

 

The processor data sheet says it has a 32-digit redial memory.  I'm not exactly sure what that means, but it seems as if this is where the information is stored.

 

 

3) Building the Frankenlight:

 

My circuit board had multiple pairs of red/black wires coming out.  Since these were probably used to transfer power I decided I could safely use them as input voltage lines.  I also wanted to use the switch to control my LED.  Using the DMM, I measured the resistance between various pins on the switch in the two positions.  I found two pins that had a very low resistance in one state, and a very high resistance in the other.  I traced where the lines on the PCB went from those pins; luckily, one went to one of the black wires coming off the board.  I soldered a wire from the red input to my perf board, connecting to my LED and resistor, then soldered a wire from the perf board back to the main circuit board.  This completed my circuit and safely let me use my switch to control the LED.

 

Schematics:

 

Schematics can be found at: http://imgur.com/a/JnQpk

 

Video:

 

Comments (0)

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