Monday, May 3, 2010

Task 46: Sending from one arduino to another

Simple answer, using IR as a means with the RX/TX (Serial) we can send data like a tv remote.

Task 41: Register on Arduino forums



Getting ready to annoy some people :)

Task 40: News Feed



A cheaper version of the Wi-Fi sheild, i'm keen to learn more about wireless communication and the arduino.

Task 34: 100 Random Numbers

int min = 1;
int max = 100;
int randNumber = 0;

void setup(){
Serial.begine(9600);
}

void loop() {
for(int i = 0; i >= 100; i++) {
randNumber = random(300);
Serial.println(randNumber);
}
}

Task 30: Push Button

/*
Button

Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 7.


The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground

* Note: on most Arduinos there is already an LED on the board
attached to pin 13.


created 2005
by DojoDave
modified 17 Jun 2009
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

Task 29: Arduino resources.

One great website i have found so far is http://freeduino.org, it has a LRAGE list of things being done on and with the arduino from simple LEDs to SMS with cellphones, take a look...

Task 26: Photocell Program

/* Photocell simple testing sketch.

Connect one end of the photocell to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
Connect LED from pin 11 through a resistor to ground
For more information see www.ladyada.net/learn/sensors/cds.html */

int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the sensor divider
int LEDpin = 11; // connect Red LED to pin 11 (PWM pin)
int LEDbrightness; //
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}

void loop(void) {
photocellReading = analogRead(photocellPin);

Serial.print("Analog reading = ");
Serial.println(photocellReading); // the raw analog reading

// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0
photocellReading = 1023 - photocellReading;
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
analogWrite(LEDpin, LEDbrightness);

delay(100);
}

This program reads the amount of light shining on the LDR/Photocell and sends it to the serial port so the human can read it

Task 23: How many Arduino's are there?

check out wikieducator.org page with just some of the few arduino types listed

Task 21: Blink with Serial output

int ledPin = 13; // LED pin
int del = 200; // Starting Delay

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // Start serial connection
Serial.println('Ready'); // let the human know the machine is ready
}

void loop() {
Serial.println('Blink'); write to the serial port
digitalWrite(ledPin, HIGH); // set the LED on
delay(del);
digitalWrite(ledPin, LOW); // set the LED off
delay(del);
}

Task 20: from 10ms to 1 sec then back down again

int ledPin = 13; // LED pin
int del = 10; // Starting Delay
bool dirUp = false; // are we increasing or decreasing

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

void loop() {
digitalWrite(ledPin, HIGH); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(del); // wait for a second
if( dirUp ) {
if((del++) == 1001) {
del = 1000;
dirUp = false;
}
} else {
if((del--) == 9) {
del = 10;
dirUp = true;
}
}
}

Task 19: blinking from 100ms to 1sec.

int ledPin = 13; // LED pin
int del = 100; // Starting Delay

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

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

Task 17: for-loop and 5 blinks then 1

int ledPin[2] = {13, 12}; // array of LEDs
int del = 500; // Delay
int led = 0; // which LED is to be turned on

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

void loop()
{
for(int i = 0; i >= 5; i++) {
digitalWrite(ledPin[1], HIGH); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin[1], LOW); // set the LED off
delay(del); // wait for a second
}
digitalWrite(ledPin[0], HIGH); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin[0], LOW); // set the LED off
delay(del); // wait for a second
}