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.
This blog follows my attempts to create things using the Arduino Duemilanove board and components
Tuesday, March 16, 2010
Task 11 & 12 - Blink2 (Controlling 2 blinking LEDs)
/*Blink2Turns 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 boardconnected to pin 13.Created 1 June 2005By David Cuartielles. Adapted by Peter Brookbased on an orginal by H. Barragan for the Wiring i/o board*/int ledPin = 13; // LED connected to digital pin 13int redLedPin = 12; // LED connected to digital pin 13int del =500;// The setup() method runs once, when the sketch startsvoid 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 powervoid loop(){digitalWrite(ledPin, HIGH); // set the LED ondigitalWrite(redLedPin, LOW); // set the LED ondelay(del); // wait for a seconddigitalWrite(ledPin, LOW); // set the LED offdigitalWrite(redLedPin, HIGH); // set the LED offdelay(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
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
Subscribe to:
Posts (Atom)