Hide minor edits - Show changes to markup

July 16, 2007, at 04:35 PM
by

- Added line 34:

July 16, 2007, at 04:35 PM
by

- Changed line 13 from:

x-- ; // decrement x by one and returns the old value of x @]

to:

x-- ; // decrement x by one and returns the old value of x

July 16, 2007, at 04:35 PM
by

- clarifying x++ and ++x, etc.Changed lines 10-12 from:

x++ ; // equivalent to the expression x = x + 1; x-- ; // equivalent to the expression x = x - 1; @]

to:

x++; // increment x by one and returns the old value of x ++x; // increment x by one and returns the new value of x

x-- ; // decrement x by one and returns the old value of x @] --x ; // decrement x by one and returns the new value of x @]

Changed lines 18-19 from:

x: any variable type

to:

x: an integer or long (possibly unsigned)

Changed lines 22-23 from:

Incremented or decremented variable

to:

The original or newly incremented / decremented value of the variable.

Changed lines 27-30 from:

x++; // x now contains 3 x--; // x contains 2 again@]

to:

y = ++x; // x now contains 3, y contains 3 y = x--; // x contains 2 again, y still contains 3 @]

Deleted lines 31-32:

Deleted line 33:

July 16, 2007, at 12:18 PM
by

- July 16, 2007, at 12:17 PM
by

- Changed line 23 from:

[@x = 2; // x now contains 2

to:

[@x = 2;

July 16, 2007, at 12:17 PM
by

- Changed lines 24-27 from:

x++; // x now contains 3 x--; // x contains 2 again@]

to:

x++; // x now contains 3 x--; // x contains 2 again@]

July 16, 2007, at 12:16 PM
by

- July 16, 2007, at 12:16 PM
by

- Deleted lines 4-7:

The ++ operator is

The -- operator is equivalent to the expression x = x - 1;

July 16, 2007, at 12:14 PM
by

- Changed lines 3-4 from:

to:

July 16, 2007, at 12:08 PM
by

- Deleted lines 26-28:

Deleted lines 31-63:

// check a sensor every 10 times through a loop void loop(){ i++; if ((i % 10) == 0){ // read sensor every ten times through loop x = analogRead(sensPin); } / ... } // setup a buffer that averages the last five samples of a sensor int senVal[5]; // create an array for sensor data int i, j; // counter variables long average; // variable to store average ... void loop(){ // input sensor data into oldest memory slot sensVal[(i++) % 5] = analogRead(sensPin); average = 0; for (j=0; j<5; j++){ average += sensVal[j]; // add up the samples } average = average / 5; // divide by total

the modulo operator will not work on floats

July 16, 2007, at 12:07 PM
by

- Added line 13:

[@

Changed lines 15-17 from:

x-- ; // equivalent to the expression x = x - 1;

to:

x-- ; // equivalent to the expression x = x - 1; @]

July 16, 2007, at 12:06 PM
by

- Added line 14:

July 16, 2007, at 12:06 PM
by

- Changed lines 1-8 from:

Increment a variable

x++;

to:

The ++ operator is

The -- operator is equivalent to the expression x = x - 1;

Increment or decrement a variable

x++ ; // equivalent to the expression x = x + 1; x-- ; // equivalent to the expression x = x - 1;

x: any variable type

Incremented or decremented variable

x = 2; // x now contains 2 x++; // x now contains 3 x--; // x contains 2 again

// check a sensor every 10 times through a loop void loop(){ i++; if ((i % 10) == 0){ // read sensor every ten times through loop x = analogRead(sensPin); } / ... } // setup a buffer that averages the last five samples of a sensor int senVal[5]; // create an array for sensor data int i, j; // counter variables long average; // variable to store average ... void loop(){ // input sensor data into oldest memory slot sensVal[(i++) % 5] = analogRead(sensPin); average = 0; for (j=0; j<5; j++){ average += sensVal[j]; // add up the samples } average = average / 5; // divide by total

the modulo operator will not work on floats

July 16, 2007, at 11:51 AM
by

- Added lines 1-8:

Increment a variable

x++;