Tuesday, March 16, 2010

Arduino Keywords

setup()
This is the function that tells the arduino how to set its self up.

loop()
This is what the arduino is to do while it is running.

analogRead(pinnumber)
read an analog value (0 -> 1023) from the pinnumber given

Serial.print()
print ASCII to the serial

Serial.println()
Print ASCII to the serial port but also add a line break after

pinMode(pinnumber, mode)
pinnumber = the number of the digital pin on the arduino board.
mode = Can be ether 'INPUT' for receving data or 'OUTPUT' for sending data.

digitalRead(pinnumber)
pinnumber = the number of the digital pin on the arduino board.

Task 11 & 12 - Blink2 (Controlling 2 blinking LEDs)

/*
Blink2
Turns on a LED on for half a second, then off for half a second, repeatedly. It also does the same to an off-board LED connected to pin 12 so that when one LED is on the other is off.
The circuit:
* LED connected from digital pin 13 to ground via resistor.
* second LED connected from digital pin 12 to ground via resistor. I used 330 ohms.
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13.
Created 1 June 2005
By David Cuartielles. Adapted by Peter Brook

based on an orginal by H. Barragan for the Wiring i/o board
*/

int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(redLedPin, HIGH); // set the LED off
delay(del); // wait for a second
}

Task 10 - Blink at 10ms

/*
Blink

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

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board and Blink by David Cuartielles

*/

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

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(10);
digitalWrite(ledPin, LOW); // set the LED off
delay(10);
}

Task 9 - Blink while LED is off longer then it is on

/*
Blink

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

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board and Blink by David Cuartielles

*/

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

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(500); // wait half a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}

Task 8 - Blink while LED is on longer then the off time

/*
Blink

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

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board and Blink by David Cuartielles

*/

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

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(500); // wait half a second
}

Tuesday, March 9, 2010

LED Mono Color Matrix Completed





















This is my home made board for my LED Matrix, its a 5x5 grid of Green LEDs, now i can move on and start the programming.

LED Assignment

My LED assignment is a martix, using a 5x5 grid of Green LEDs i will make a simple pattern turning LEDs on and off using the arduino