Sunday, May 2, 2010

Initial Arduino Terms

Arduino sketches are built around two hard-wired procedure names:
  • One for initialisation: setup() //this just runs once, at the start of sketch processing
  • One for continuous operation: loop() //this runs continuously, until interrupted

025: Arduino Glossary

Here is a link to my Arduino Glossary. It is actually another page on this blog. When I created it, I was under the impression that this corresponded to task 029, which is why the page has a strange name.

024: Light-Dependent Resistors

I am looking forward to playing with my LDR. My Minor Project is going to be to do with "dithering" monotone sounds to try and model musical chords; I could possibly combine this with the LDR to make a light-controlled theremin.

If I can borrow a couple more LDRs, I could make a chordal theremin...

Here is the Ladyada Site. It has more information than I can currently handle on the technicals of LDRs; I plan to refer to it whenever I get confused by the behaviour of mine.

023: Another Arduino Type

Here is The Pinguino

I also found a reference to a Fartduino, for monitoring methane from cattle, but that was just a joke.

021, 022: Blinking and Swearing

Yet again, I have decided just to do the last one of this series.

Here is the code for Task 022:

...

Here is a Photo:

...

Here is a Video Clip:

...

19, 20: Winking and Ramping

Once again, I have decided just to do the last one of this series.

Here is the code for Task 020:

...

Here is a Photo:

...

Here is a Video Clip:

...

012, 013, 014, 015, 016, 017, 018: Variations on Blinking Themes

I have decided just to do the last one of this series of tasks, as I am getting behind.

I find the programming of these tasks relatively quick, but the posting of code, photos and video clips takes a while.

Here is the code for Task 018:

...

Here is a Photo:

...

Here is a Video Clip:

...

Sunday, March 7, 2010

011 Blink2 Sketch

This sketch shows the on-board LED and a breadboarded LED going on and off alternately. I copied it straight from Peter's blog:

/*
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
}


Here is a picture:

...

and a video clip:

...

of it working. Thanks to my mate Roy for helping me set up the circuit (my first ever breadboard!) and for taking and getting me the clips.

LED Project

For my LED project, I have proposed a traffic light system, with red, amber and green lights. I will control corrspondingly coloured LEDs in sequence. I will model an UK traffic light as the sequence is prettier than in NZ, and gives me the opportunity to show a more complex pattern.

If this is insufficient, and if time permits, I will add a pedestrian control to the traffic light, to break the sequence on request to allow pedestrians to cross in safety.

010 (again) Flicker Sketch

This sketch shows the LED going on for 12 millseconds then off for 13 millisecond intervals. In ambient light, I can just see the flickering - I find this more distinguishable than when the light is on for 13 millseconds then off for 12 milliseconds:

/*
Flicker

Turns on an LED on for 12 millisecond, then off for 13 millisecond, repeatedly.

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.


Created 5th March 2010
By Mike Goodwin

*/

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(12); // wait for 12 milliseconds
digitalWrite(ledPin, LOW); // set the LED off
delay(13); // wait for 13 milliseconds
}

010 Dither Sketch

This sketch shows the LED going on and off at 10 millisecond intervals. In most lights, I can't see the flickering:

/*
Dither

Turns on an LED on for one centisecond, then off for one centisecond, repeatedly.

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.


Created 5th March 2010
By Mike Goodwin

*/

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); // wait for a centisecond
digitalWrite(ledPin, LOW); // set the LED off
delay(10); // wait for a centisecond
}

Thursday, March 4, 2010

009: Occult Sketch

Occulting is the opposite of flashing, where the light is on for longer than it is off. I learned that in a course on boatcraft. I increased the shorter interval to 100ms to make it doubly different:

/*
Occult

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

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example.


Created 5th March 2010
By Mike Goodwin

*/

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(100); // wait for a centisecond
}

008: Flash Sketch

This is based on the Blink sketch, with the timing changed. The Flash duration is very low (10ms) but visible:

/*
Flash

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

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.


Created 5 March 2010
By Mike Goodwin

*/

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); // wait for a centisecond
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}

Sunday, February 28, 2010

006: Sketch Folders


I have putArduino Sketch folders on my USB pen drive, my H:\ Drive in class, and the hard drive of my netbook. I hope I don't get too confused!

(update: I have got confused, and keep losing sketches - either it is because of the bad H:\ drive mapping in D208 or I am closing the Arduino environment without saving for some reason.)

007: Blink Sketch

Here is the original Blink sketch. I copied it straight out of the Examples folder from within the Arduino environment. I changed the formatting because I don't like the provided brace indenting:


/*
Blink

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

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example.


Created 1 June 2005
By David Cuartielles

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

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

*/

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(1000); // wait for a second
}

Thursday, February 25, 2010

005: Arduino YouTube Clips

Here are some links to Arduino applications that tickled my fancy:

Here is a link to an Arduino Drumkit. I am not yet sure what is going on because I have not listened to the audio (forgot my headphones.)

Here is a single-octave, chromatic Arduino Keyboard. It is a bit buzzy, but I like it because it is self-contained.

Here is an Arduinocaster Electric Guitar (although I would have preferred an ArduinoSG :-) If I thought it could teach me to play, I might build one.



This is my favourite: Using an Arduino to hack a guitar pedal. I have an old Zoom 1010 guitar pedal, whose user interface and sound quality are not much nicer than the Arduino's.

Thursday, February 18, 2010

My Arduino Chip

According to the engraving, my Arduino board is a Duemilanove with an ATMega328P-PU chip.

Here is a link to the specification sheet for the AT328:

ATMega328 Datasheet

It is 555 pages long, so here is a link to the 32-page summary sheet:

ATMega328 Summary Datasheet

Atmel Site

Here is a link to the Atmel site:

Atmel site

My friend Terry tells me that Atmel gear is not nearly as good as PicAxe gear:

PicAxe site

but I don't know much about hardware, so I can't say.

Picture of an Arduino


Here is a picture of an Arduino, I am not sure what version.
This particular Arduino is running a Theremin, which is an early type of electronic musical instrument - when I was a boy in the 1960s, the scary theme tune for Doctor Who (in black and white) was played on a Theremin.
Here is a link to the site providing the picture:

Hello World!

This is my blog for the Embedded Systems course.

Here are some important links relating to the course:

Peter's Course Blog

002, 003: Contacts for the Embedded class

001: This Blog

Peter's Chip8 Blog

Arduino Website

Arduino Website Forum

MindKits Web Site