Tutorial.Array History

Show minor edits - Show changes to markup

May 02, 2012, at 04:07 PM by Scott Fitzgerald -
Changed line 43 from:
to:
November 16, 2011, at 04:17 AM by Scott Fitzgerald -
Changed line 43 from:
to:
September 30, 2011, at 03:19 AM by Scott Fitzgerald -
Changed line 43 from:
to:
September 23, 2010, at 10:40 PM by Christian Cerrito -
Changed lines 3-4 from:

Arrays

to:

Arrays

September 18, 2010, at 12:08 AM by Christian Cerrito -
Changed lines 5-6 from:

This variation on the For Loop example shows how to use an Array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

to:

This variation on the For Loop example shows how to use an array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

September 18, 2010, at 12:07 AM by Christian Cerrito -
Changed lines 7-8 from:

The For Loop example shows you how to light up a series of LEDs attached to pins 2 through 7 of the Arduino. But the limitation is that the pins have to be numbered contiguously, and they have to be turned on in sequence. This example shows you how you can turn on a sequence of pins whose numbers are neither contiguous nor necessarily sequential. To do this is, you can put the pin numbers in an array and then use for loops to iterate over the array.

to:

The For Loop example shows you how to light up a series of LEDs attached to pins 2 through 7 of the Arduino, with certain limitations (the pins have to be numbered contiguously, and the LEDs have to be turned on in sequence).

This example shows you how you can turn on a sequence of pins whose numbers are neither contiguous nor necessarily sequential. To do this is, you can put the pin numbers in an array and then use for loops to iterate over the array.

Deleted line 12:
September 18, 2010, at 12:03 AM by Christian Cerrito -
Changed lines 5-6 from:

This variation on the For Loop example shows how to use an Array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

to:

This variation on the For Loop example shows how to use an Array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

Changed lines 44-58 from:
to:
September 16, 2010, at 10:16 PM by Tom Igoe -
Changed line 42 from:
to:
September 16, 2010, at 08:03 AM by Christian Cerrito -
Changed lines 5-6 from:

This variation on the For Loop example shows how to use an array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

to:

This variation on the For Loop example shows how to use an Array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

September 16, 2010, at 07:55 AM by Christian Cerrito -
Changed lines 37-38 from:
to:
September 16, 2010, at 07:55 AM by Christian Cerrito -
Added lines 24-25:

Connect six LEDS, with 220 ohm resistors in series, to digital pins 2-7 on your Arduino.

September 16, 2010, at 07:54 AM by Christian Cerrito -
Added lines 14-21:

Hardware Required

  • Arduino Board
  • (6) 220 ohm resistors
  • (6) LEDs
  • hook-up wire
  • breadboard

September 15, 2010, at 11:28 PM by Christian Cerrito -
Changed line 32 from:
to:
February 24, 2010, at 04:07 AM by Tom Igoe -
Changed lines 32-51 from:
 /*
   Arrays
  
  Demonstrates the use of  an array to hold pin numbers
  in order to iterate over the pins in a sequence. 
  Lights multiple LEDs in sequence, then in reverse.
  
  Unlike the For Loop tutorial, where the pins have to be
  contiguous, here the pins can be in any random order.
  
  The circuit:
  * LEDs from pins 2 through 7 to ground
  
  created 2006
  by David A. Mellis
  modified 5 Jul 2009
  by Tom Igoe 
  
  http://www.arduino.cc/en/Tutorial/Array
  */
to:
Deleted lines 33-67:
 int timer = 100;           // The higher the number, the slower the timing.
 int ledPins[] = { 
   2, 7, 4, 6, 5, 3 };       // an array of pin numbers to which LEDs are attached
 int pinCount = 6;           // the number of pins (i.e. the length of the array)

 void setup() {
   int thisPin;
   // the array elements are numbered from 0 to (pinCount - 1).
   // use a for loop to initialize each pin as an output:
   for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
     pinMode(ledPins[thisPin], OUTPUT);      
   }
 }

 void loop() {
   // loop from the lowest pin to the highest:
   for (int thisPin = 0; thisPin < pinCount; thisPin++) { 
     // turn the pin on:
     digitalWrite(ledPins[thisPin], HIGH);   
     delay(timer);                  
     // turn the pin off:
     digitalWrite(ledPins[thisPin], LOW);    

   }

   // loop from the highest pin to the lowest:
   for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
     // turn the pin on:
     digitalWrite(ledPins[thisPin], HIGH);
     delay(timer);
     // turn the pin off:
     digitalWrite(ledPins[thisPin], LOW);
   }
 }
August 27, 2009, at 08:47 PM by Tom Igoe -
Added lines 20-22:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

July 06, 2009, at 08:12 PM by Tom Igoe -
Changed line 66 from:
   for (int thisPin = 0; i < pinCount; thisPin++) { 
to:
   for (int thisPin = 0; thisPin < pinCount; thisPin++) { 
Changed line 76 from:
   for (thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
to:
   for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
July 05, 2009, at 09:04 PM by Tom Igoe -
Added lines 1-85:

Share