Lab1 - Arduino Blinky

Submitted by thomas.may on Wed, 01/30/2013 - 15:40

Description.

To complete this lab I started with building the simple circuit described on the Lab assignment on the breadboard. On it I placed an LED, a 220 ohm resistor and 3 patch cables; (1) between the Arduino ground to the negative rail of the breadboard then another (2) from this point to the cathode (-) of the LED. From the anode (+) of the LED the 220 ohm resistor bridges to another rail on the breadboard to which the third (3) patch cable is also connected and plugged into pin13 on the Arduino compleating the LED circuit.

On the code side I loaded the Basic blinky example then made some additions to the void loop() section.

I first created 2 variables rval and rval1. Then I replaced the standard 1000ms delays between and after the digitalWrite's with the 2 int's. I difined the two int's with random(10,1000) which creates a random value on every loop that is between 10ms and 1000ms. This creates an inconsistent blinky LED light.

Components used.

1- Arduino

1 - breadboard

1- red LED

1- 220 ohm resistor

3- parch cables

Code.

 

/*

  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() {

  int rval= random(10,1000);

  int rval1= random(10,1000);

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

  delay(rval);               // wait for a second

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

  delay(rval1);               // wait for a second

}

 

Lab1.jpg
0
Your rating: None
Drupal theme by Kiwi Themes.