Purpose:
Utilize the RGB LED to made it shift colours
Equipment:
RGB LED (x1)
resistor (x1)
wires (x3)
Program Details:
i used the one off newinnovators.ca
Time to Program and Complete:
3 minutes
Results:
N/A
Photo/Video Proof:
Program:
const int RED_LED_PIN = 9;
//sets a constant value for RED_LED_PIN
const int GREEN_LED_PIN = 10;
//sets a constant value for GREEN_LED_PIN
const int BLUE_LED_PIN = 11;
//sets a constant value for BLUE_LED_PIN
int redIntensity = 0;
//sets value for redIntensity
int greenIntensity = 0;
//sets value for redIntensity
int blueIntensity = 0;
//sets value for redIntensity
const int DISPLAY_TIME =
//sets constant value for DISPLAY_TIME
void setup()
{
}
void loop()
//declares action
{
//start of loop
for (greenIntensity = 0; greenIntensity <= 255; greenIntensity+=5)
//if conditions met continue code
{
//loop inside of loop
redIntensity = 255-greenIntensity;
//sets new value for redIntensity
analogWrite(GREEN_LED_PIN, greenIntensity);
//turns on GREEN_LED_PIN to value greenIntensity
analogWrite(RED_LED_PIN, redIntensity);
//turns on RED_LED_PIN to value of redIntensity
delay(DISPLAY_TIME);
//delay time for value for DISPLAY_TIME
}
// end loop
for (blueIntensity = 0; blueIntensity <= 255; blueIntensity+=5)
//if conditions met continue code
{
//loop inside of loop
greenIntensity = 255-blueIntensity;
//sets new value for greenIntensity
analogWrite(BLUE_LED_PIN, blueIntensity);
//turns on BLUE_PIN to value bluensity
analogWrite(GREEN_LED_PIN, greenIntensity);
//turns on GREEN_LED_PIN to value greenIntensity
delay(DISPLAY_TIME);
//delay time for value for DISPLAY_TIME
}
//end of loop
for (redIntensity = 0; redIntensity <= 255; redIntensity+=5)
//if conditions met continue code
{
//loop inside of loop
blueIntensity = 255-redIntensity;
//sets new value for blueIntensity
analogWrite(RED_LED_PIN, redIntensity);
//turns on RED_PIN to value redIntensity
analogWrite(BLUE_LED_PIN, blueIntensity);
//turns on BLUE_PIN to value blueIntensity
delay(DISPLAY_TIME);
//delay time for value for DISPLAY_TIME
}
//end of loop
}
//end of loop
Program Modifications:
N/A
Helpful Tips:
References:
newinnovators.ca
Monday, 30 November 2015
Friday, 27 November 2015
Lab 4 - Potentiometer
Purpose:
To change the intervals between blinks of the LED
Equipment:
Potentiometer (X1)
resistor (X1)
LED (X1)
wires (X6)
Program Details:
I used the one of newinnovators.ca
Time to Program and Complete:
5 minutes
Results:
i have to move the potentiometer so it would fit
Photo/Video Proof:
Photo or video of you actually doing this lab
Program:
int sensorPin = A0;
//assigns sensorPin to analog pin 0
int ledPin = 13;
//sets ledPin to pin 13
int sensorValue = 0;
//sets a value for sensorValue
void setup()
//declares a setup
{
//start of function
pinMode(ledPin, OUTPUT);
//sets ledPin as an output
}
//end of function
void loop()
//declares a loop
{
// start of loop
sensorValue = analogRead(sensorPin);
//gives sensorValue a value of what sensorPin is currently at
digitalWrite(ledPin, HIGH);
//sets the LED to maximum power
delay(sensorValue);
//delays the code for the value of sensorValue
digitalWrite(ledPin, LOW);
//sets the LED to minimum power
delay(sensorValue);
//delays the code for the value of sensorPin
}
//end of loop
Program Modifications:
N/A
Helpful Tips:
Make sure the wires go to the correct ports and pins
References:
newinnovators.ca
To change the intervals between blinks of the LED
Equipment:
Potentiometer (X1)
resistor (X1)
LED (X1)
wires (X6)
Program Details:
I used the one of newinnovators.ca
Time to Program and Complete:
5 minutes
Results:
i have to move the potentiometer so it would fit
Photo/Video Proof:
Photo or video of you actually doing this lab
Program:
int sensorPin = A0;
//assigns sensorPin to analog pin 0
int ledPin = 13;
//sets ledPin to pin 13
int sensorValue = 0;
//sets a value for sensorValue
void setup()
//declares a setup
{
//start of function
pinMode(ledPin, OUTPUT);
//sets ledPin as an output
}
//end of function
void loop()
//declares a loop
{
// start of loop
sensorValue = analogRead(sensorPin);
//gives sensorValue a value of what sensorPin is currently at
digitalWrite(ledPin, HIGH);
//sets the LED to maximum power
delay(sensorValue);
//delays the code for the value of sensorValue
digitalWrite(ledPin, LOW);
//sets the LED to minimum power
delay(sensorValue);
//delays the code for the value of sensorPin
}
//end of loop
N/A
Helpful Tips:
Make sure the wires go to the correct ports and pins
References:
newinnovators.ca
Wednesday, 25 November 2015
Challenge 2 - Multi LEDs
Challenge Name | Running Man |
Author | Kyle Chan |
Credit | I referenced the code off newinnovstors.com |
Difficulty Level (1-5) | 3. |
Time To Complete | 5 minutes |
Challenge Hint | |
Description | The four LEDs blink in different orders |
Answer |
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 Name | Christmas Time |
Author | Kyle Chan |
Credit | I referenced the code off newinnovators.ca |
Difficulty Level (1-5) | 3 |
Time To Complete | 5 minutes |
Challenge Description | Pressing the button turns on off the green and turns on the red |
Hint | copy and paste really helps |
Answer | const 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
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
N/A
Helpful Tips:
make sure the wires lead to the right port
References:
newinnovators.ca
Subscribe to:
Posts (Atom)