Wednesday 18 November 2015

Lab 2 - Multi LEDs

Purpose:
Make multiple LEDs blink one after the other

Equipment:
LEDs (x 4)
Resistor
Wires (x 3)
Arduino Uno
Breadboard



USB cable

Program Details:
I used the program off newinnovators.ca

Time to Program and Complete:
3 minutes

Results:
N/A

Photo/Video Proof:


























Program
:
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
//this tells the program what ledPin1, 2, 3 and 4 are equal to

void setup ()
//the code underneath is isolated from the other code
{
//anything underneath is part of the above code
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
//identifies the pinMode1, 2, 3 and 4 as either and output or input
}
//this is the end of the isolated code

void loop()
//the isolated code will loop forever
{
//start of the loop function
  int delayTime = 100;
//sets what delayTime is equal to
  digitalWrite(ledPin1, HIGH);
//sets the LED value to high
  delay(delayTime);
//delays the code for what delayTime is equal to
  digitalWrite(ledPin2, HIGH);
//sets the LED2 value to high
  delay(delayTime);
  digitalWrite(ledPin3, HIGH);
//sets the LED3 value to high
  delay(delayTime);
  digitalWrite(ledPin4, HIGH);
//sets the LED4 value to high
  delay(delayTime);

  digitalWrite(ledPin1, LOW);
//sets the LED1 value to low
  delay(delayTime);
  digitalWrite(ledPin2, LOW);
//sets the LED2 value to high
  delay(delayTime);
  digitalWrite(ledPin3, LOW);
//sets the LED3 value to high
  delay(delayTime);
  digitalWrite(ledPin4, LOW);
//sets the LED4 value to high
  delay(delayTime);
}
//this is the end of the loop

Program Modifications:
N/A

Helpful Tips:
Make sure the wires go to the correct ports

References:
newinnovators.ca

No comments:

Post a Comment