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

QuinnMatheis_LabReport2

Page history last edited by Vivien Tsao 10 years, 9 months ago

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

 

The code already blinks, but should I want to make the LED blink from scratch I would add in the “void loop()” command and type in everything inside the loop.

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

 

Inside the void loop, there are two commands labeled “delay.” In here, we adjust the number to the corresponding milliseconds we want to use as the delay between “high” and “low” (On and Off).

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

 

We would want to use a resistor…since the Arduino keeps a steady voltage (5V) and the max DC Forward Current of my GREEN LED is 25 mA, then (when accounting for a 1.8V drop), the resistor I need follows the Ohm’s Law of V=IR, or

 

128 Ohm Resistor.

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

 

Under the “const int (variable name)” commands (which happen to be the very first lines of actual code, not comments), you set the numbers to corresponding pins you wish to use.

 

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

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

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

 

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

 

Since the code is preset to work with pin 9, I don’t need to change anything. However, the first line of code says:

 

int ledPin = 9; // LED connected to digital pin 9

 

This number corresponds to the pin we want to use.

b) How would you change the rate of fading?

 

The part of the code in the for loop (within the void loop) that says “fadevalue + (or -)= (number here),” we can change this number to increase the rate of fading.


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?

 

You can change to increment value in the “fadevalue” to 1, which is, no matter what happens to it, whether multiplied exponentially or logarithmically, will always increase values by 1, and make the light appear to brighten and darken more linearly.

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

 

Again, using Ohm’s Law of V=IR, and accounting for the 5V output the arduino uses and the 3.2V drop the bright LED has, we get the equation 1.8V = .030(mA)R or

 

60 Ohms.

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

 

Because I am using a keyboard circuit, there is no computation going on inside it. It recognizes what keys are pressed and displays an LED ON if there is a special (CAPS, NUM LOCK) key triggered.

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 an LED recognition device (used to detect if “CAPS LOCK” is on).

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?

 

It is powered through the computer power, but I will hack in the USB recognition and use that as input power.

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

 

As mentioned there is a sort of information stored…it recognizes if a key is “On” or not, but no real use of hard memory.

****Important to mention: The LED worked in testing and before soldering, but afterward it did not. What ended up happening that I didn’t think important was that a jumper wire I soldered on brock off and so the circuit was not complete.****

 

Comments (1)

Vivien Tsao said

at 12:06 am on Jul 15, 2013

Good job!

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