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

BenjaminWilliams_Lab2

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

Part A. Assemble Kits

Completed in lab. 

 

Part B. Arduino micro LED!

 

1. Blinking LEDs with Arduino Micro

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

 

a. Lines 10, 19 and 20 (highlighted below in yellow)

Line 10: Specifies which LED takes the code's orders

Line 19: Ensures that the code works in a loop

Line 20: Turns the LED (specified in line 10) on

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

 

b. Lines 21 and 23 (highlighted below in blue)

Line 21: Specifies the delay time in milliseconds 

Line 23: Specifies the delay time in milliseconds

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

 

c. I would want to add a voltage regulator to protect the board and ensure that the LED doesn't blow

 


/*

  Blink

  Turns on an LED on for one second, then off for one second, repeatedly.

 

  This example code is in the public domain.

 */

 

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int led = 13;

 

// the setup routine runs once when you press reset:

void setup() {                

  // initialize the digital pin as an output.

  pinMode(led, OUTPUT);     

}

 

// the loop routine runs over and over again forever:

void loop() {

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);               // wait for a second

  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);               // wait for a second

}


 

2. Toggle LEDs on and off using Arduino Micro

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

 

a. The below lines help 

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;

const int ledPin = 13;

 

int buttonState = 0;

 

void setup() {

 

pinMode(ledPin, OUTPUT);

pinMode(buttonPin, INPUT);

}

 

void loop(){

 

buttonState = digitalRead(buttonPin);

 

if (buttonState == LOW) {

 

digitalWrite(ledPin, HIGH);

}

else {

 

digitalWrite(ledPin, LOW);

}

}

 

3. Fading LEDs on and off using Arduino Micro

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

 

a) My code was already on Pin 9 so I didn't have to change much. However, modify the code to correspond with your LED pin you need to change:

 

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

b) How would you change the rate of fading?

 

To change the rate of fading you change the delay time on lines 32-33

 

  // wait for 30 milliseconds to see the dimming effect    

  delay(30);  

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?

 

c) Using PWM. Pulse-width modulation is the same feature that allowed me to create the breathing Apple LED computer effect. By turning the LED on and off really fast the eye is tricked into thinking that the LED is fading very linearly.

 

Also, changing the delay time to 100 mS would make the light appear to fade "linearly" 

 

Part C. Frankenlight

 

3. Fading LEDs on and off using Arduino Micro

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

 

a.                                                                                                               V = IR

V/I = R

 

V = 3.2 V (Voltage Drop)

I = 30 mA

 

3.2/30 = R = 107 Ω

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

 

b. There's a few voltage regulators and capacitors on my device. The voltage regulators ensure that the output voltage doesn't go over a certain limit. The capacitors temporarily hold energy but also act as a resistor.

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?

 

b. It's not very clear how the device is powered. I only have a perfboard and an attached metal cylindrical component that looks like batteries could possibly be attached to power the board. 

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

 

No. The only information comes from the Arduino Micro that was connected to the perfboard. 

Schematic:


Frankenlight video below!

 


 

 

 

Comments (1)

Vivien Tsao said

at 1:15 am on Jul 15, 2013

Good job!

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