Found a slight issue. Its more of a page layout issue then anything.
Due to the page layout on page 44 the code for project 6 doesn't copy and paste over to the IDE well. With all the projects i highlight, copy, and paste the code from the PDF to the IDE. Problem is the wrap around on the code commentary causes some of the commentary to fall on a new line. So without the "//" in front of it the IDE thinks its functioning code. I've highlighted the problem areas.
// Create array for LED pins
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10,
11, 12, 13};
int ledDelay; // delay between changes
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
int potPin = 2; // select the input
[glow]pin for the potentiometer[/glow]
void setup() {
// set all pins to output
for (int x=0; x<10; x++) {
pinMode(ledPin[x], OUTPUT); }
changeTime = millis();
}
void loop() {
// read the value from the pot
ledDelay = analogRead(potPin);
// if it has been ledDelay ms since
[glow]last change[/glow]
if ((millis() - changeTime) >
ledDelay) {
changeLED();
changeTime = millis();
}
}
void changeLED() {
// turn off all LED's
for (int x=0; x<10; x++) {
digitalWrite(ledPin[x], LOW);
}
// turn on the current LED
digitalWrite(ledPin[currentLED],
HIGH);
// increment by the direction value
currentLED += direction;
// change direction if we reach the
[glow]end[/glow]
if (currentLED == 9) {direction =
-1;}
if (currentLED == 0) {direction = 1;}
}
So you can see where the IDE will come up with errors as you try to compile it as is. many beginners may have problems with that.
BTW i still had trouble getting the PDF to upload threw Firefox. But was able to get it just fine threw IE.
Also on page 42, the bottom left paragraph has a typo.
In our mail loop we check that at least ledDelay milliseconds
have passed since the last change of LED[ch700]s
and if so it passes control to our function. The reason
we are only going to pass control to the changeLED()
function in this way, rather than using delay()
commands, is to allow other code if needed to run [glow]int
he[/glow] main program loop (as long as that code takes less
than ledDelay to run.
I've seen others but i'm pretty sure most of them are Queen's English vs. American English differences. Basically my poor English compared to your proper English.
Page 45:
We need [glow]to[/glow] set our delay using the potentiometer so we
will simply use the direct values read in from the pin to
adjust the delay between 0 and 1023 milliseconds. We
do this be [glow]by[/glow] directly reading the value of the
potentiometer pin into ledDelay. Notice that we do not
need to set an analog pin to be an input or output like
we need to with a digital pin.
OK i'll stop now. No need to nit pick or i'll never hear the end of it when i have a typo in here. lol