Wednesday, 25 November 2015

Challenge 2 - Multi LEDs


Challenge NameRunning Man
AuthorKyle Chan
CreditI referenced the code off newinnovstors.com
Difficulty Level (1-5)3.
Time To Complete5 minutes
Challenge
Hint

DescriptionThe four LEDs blink in different orders 
























Answer






























int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;

void setup ()

{
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
}

void loop()
{
  {
    int delayTime = 100;
    int delayTime1 = 200;
    digitalWrite(ledPin1, HIGH);
    delay(delayTime1);
    digitalWrite(ledPin4, HIGH);
    delay(delayTime1);
    digitalWrite(ledPin3, HIGH);
    delay(delayTime1);
    digitalWrite(ledPin2, HIGH);
    delay(delayTime1);
    
    digitalWrite(ledPin1, LOW);
    delay(delayTime1);
    digitalWrite(ledPin4, LOW);
    delay(delayTime1);
    digitalWrite(ledPin3, LOW);
    delay(delayTime1);
    digitalWrite(ledPin2, LOW);
    delay(delayTime1);
    
  }
}

Tuesday, 24 November 2015

Challenge 3 - Button Control

Challenge NameChristmas Time
AuthorKyle Chan
CreditI referenced the code off newinnovators.ca
Difficulty Level (1-5)3
Time To Complete5 minutes
Challenge DescriptionPressing the button turns on off the green and turns on the red


Hintcopy and paste really helps
Answerconst int buttonPin1 = 2;
const int buttonPin2 = 3;
const int ledPin1 = 10;
const int ledPin2 = 9;
const int ledPin4 = 11;
const int ledPin3 = 8;

int buttonState1 = 0;
int buttonState2 = 0;

void setup()
{
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
}

void loop()
{
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  if (buttonState1 == HIGH)
  {
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin4, HIGH);
    delay(1000);
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin4, LOW);
   
  }
  else if (buttonState2 == HIGH)
  {
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    delay(1000);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
  }
}

Friday, 20 November 2015

Lab 3 - Button Control

Purpose:
Use the button to turn on and off the LED

Equipment:
Push button (x 2)
Resistor
LED
Wires (x 6)

Program Details:
I used the program off newinnovators.ca

Time to Program and Complete:
5 minutes

Results:
N/A



Photo/Video Proof:



























Program:

const int buttonPin = 2;
//makes a variable called buttonPin hold a value of 2. Const makes the variable constant and unchanging
const int ledPin = 9;
//makes a variable called ledPin hold a value of 9. Const makes the variable constant and unchanging

int buttonState = 0;
//makes a variable called buttonState with a value of 0

void setup()
//the code underneath is isolated from the other code
{
//anything underneath is part of the above code
  pinMode(ledPin, OUTPUT);
//identifies the ledPin as either and output or input
  pinMode(buttonPin, INPUT);
//identifies the buttonPin as either and output or input
}

void loop()
//the code underneath will loop continuously
{
//beginning of loop function
  buttonState = digitalRead(buttonPin);
//checks to see if a variable is true
  if (buttonState == HIGH)
//if buttonState is equal to HIGH
  {
//beginning of loop
    digitalWrite(ledPin, HIGH);
//gives power to ledPin 
  }
//ends loop
  else
//if the original condition is not true do this:
  {
//beginning of loop
    digitalWrite(ledPin, LOW);
//gives LOW power to ledPin
  }
//end loop
}
//end loop

Program Modifications:
N/A

Helpful Tips:
make sure the wires lead to the right port

References:
newinnovators.ca

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

Challenge 1 - LED Challenge

Challenge NameHello.... IT'S ME
AuthorKyle Chan
CreditI used the basics of Lab 1
Zach gave me the idea
Difficulty Level (1-5)Level 4
Time To Complete10 minutes
Challenge Description

The LED blinks reflecting the morse code for the word "Hello"

Hintcopy and paste is your best friend
Answer
int ledPin = 13;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(300);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(300);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(300);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(300);
  digitalWrite(ledPin, LOW);
  delay(150);
  digitalWrite(ledPin, HIGH);
  delay(300);
  digitalWrite(ledPin, LOW);
  delay(150);
}

Lab 1 - LED Lab

Purpose:
Trying to make an LED blink continuously 

Equipment:
LED
Resistor
Wire (x3)
Arduino Uno
Breadboard
USB cable

Program Details:
i used the program of newinnovators.ca


Time to Program and Complete:
3 minutes

Results:
N/A

Photo/Video Proof:
Photo or video of you actually doing this lab




























Program
:
int ledPin = 13;  
//this tells the program what ledPin is equal to

void setup()
//the code underneath is isolated from the other code
{
//anything underneath is part of the above code
  pinMode(ledPin, OUTPUT);
//identifies the pinMode 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

  digitalWrite(ledPin, HIGH);
//sets the LED value to high
  delay(1000);
//delays the code for 1000 milliseconds
  digitalWrite(ledPin, LOW);
//sets the LED value to low
  delay(1000);
}


Program Modifications:
N/A

Helpful Tips:
Make sure that the polarity of the LED is correct

References:
newinnovators.ca