Errata

Arduino Cookbook

Errata for Arduino Cookbook, Second Edition

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed, PDF, , Other Digital Version
Page 34
16th line on the page

Where the page shows what the results of the last two lines of added code should be (text3 = text1 + " and more"; Serial.println(text3);) the result says it should show

"This is a string with more text and more"

In the Serial Monitor but the actual result should show

"This string has more text and more"

Note from the Author or Editor:
Change the text:
"This is a string with more text and more"
to:
"This string has more text and more"

Anonymous  Jun 05, 2012  May 17, 2013
Printed
Page 35
17th line

"t" missing from the word "to".

Note from the Author or Editor:
on page 35, change :
"Copies up o len characters of the String to the supplied buffer"

to"

Copies up to len characters of the String to the supplied buffer

Anonymous  Aug 19, 2012  May 17, 2013
Printed, PDF, ePub
Page 44
Discussion, paragraph 1, last sentence, last word.

Author refers to a data variable that is supposedly in the code example called "blinkRate." There is NO SUCH variable in the code example. I believe "blinkRate" should be deleted and replaced with "blinkDelay."

Note from the Author or Editor:
The fragment should use the variable blinkDelay instead of blinkRate

Anonymous  Dec 15, 2012  May 17, 2013
Printed, PDF, ePub
Page 44
bottom

int blinkDelay; // blink rate determined by this variablevoid loop()
{
if( Serial.available())
{
blinkRate = Serial.parseInt();
}
blink();
}

should be

int blinkDelay; // blink rate determined by this variable
void loop()
{
if( Serial.available())
{
blinkRate = Serial.parseInt();
}
blink();
}

Note from the Author or Editor:
The fragment at the bottom of age 44, change from:

int blinkDelay; // blink rate determined by this variable
{
if( Serial.available())
{
blinkRate = Serial.parseInt();
}

blink();
}
}

to:

void loop()
{
if( Serial.available())
{
blinkRate = Serial.parseInt();
}
blink();
}

Anonymous  Mar 03, 2013  May 17, 2013
Printed, PDF
Page 47
Bottom section of code

At the top of the code ledPin has been defined for port 13:
const int ledPin = 13;
Generally this is a good idea for code readability and debugging ease.

Near the bottom these lines do not take advantage of this:

digitalWrite(13,HIGH);
....
digitalWrite(13,LOW);

Note from the Author or Editor:
In Recipe 2.10, the sketch code on page 47 uses the explicit value 13 instead of the ledPin constant. The download sketch has been updated to use the ledPin constant.

change:
digitalWrite(13,HIGH);
delay(period);
digitalWrite(13,LOW);
to:
digitalWrite(ledPin,HIGH);
delay(period);
digitalWrite(ledPin,LOW);

Scott Austin  Aug 27, 2012  May 17, 2013
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 56
Output Example at Bottom of Page

Demo code has "Serial.println("for(j=0; j < 4; j++ )");

and output shown as:

for(j=0; i < 4; i++)

it should be:
for(j=0; j < 4; j++)

The wrong one has a lower case "I" and the right one has a lower case "J" on screen the difference between a i and a j can be hard to spot depending on your font.

Note from the Author or Editor:
The code is correct but the output listing should be changed from:
for(j=0; i < 4; i++)
to:
for(j=0; j < 4; j++)

Anonymous  Oct 09, 2012  May 17, 2013
Printed
Page 86
14th line

hiWord should be highWord (i.e. These are macro expressions: highWord performs ...)

Note from the Author or Editor:
In the discussion of Recipe 3.14 change:
"These are macro expressions: hiWord performs a 16-bit shift operation ..."
to:
"These are macro expressions: highWord performs a 16-bit shift operation ..."

Anonymous  Aug 27, 2012  May 17, 2013
Printed
Page 86
lines 22 through 25

To be consistent with the previous code in recipe 3.14 and the code in recipe 3.15, change the int variables:

loword to loWord
hiword to hiWord

Note from the Author or Editor:
In the discussion of Recipe 3.14 on page 86, the lower case 'w' in the variables should be upper case
change:
loword = lowWord(longValue);
hiword = highWord(longValue);
to:
loWord = lowWord(longValue);
hiWord = highWord(longValue);

Anonymous  Aug 27, 2012  May 17, 2013
Printed, PDF, , Other Digital Version
Page 116
2 places

Looks like you are using booleen and '&&' instead of bitwise and '&' to extract the lower byte of a variable. I am new with arduino so the mistake may be on my end.

Note from the Author or Editor:
In Recipe 4.6 on page 116
change:
longValue && 0xFFFF
to:
longValue & 0xFFFF

and change:
change:
value && 0xFFFF
to:
value & 0xFFFF

Insert the following to the See Also section on Page 118 before the text: "Also, check ..."
See Recipe 3.15 for more on handling high and low bytes.

Randy Perkins  Apr 09, 2012  May 17, 2013
PDF, ePub
Page 128
United States

The sketch on page 128 and 135 (at least) are incomplete. I got an error - "Cannot find a class or type named "Dimension"" when I tried to run the sketches.

I found the solution. The following line is missing from both sketches. Adding this line to the import section corrected:

import java.awt.Dimension;


Note from the Author or Editor:
The Processing sketches compile correctly using the latest stable release (1.5.1). However the Beta release (2.x) does require the additional include. The download code has been updated with the following additional line in the import section of the sketch:

import java.awt.Dimension;

Anonymous  Feb 05, 2013  May 17, 2013
Printed, PDF, ePub
Page 131
wiichuckSerial sketch

The sketch will not compile. I have checked all spelling etc. It always stops at nunchuck_get_data(); The error that shows up is: 'nunchuck_get_data' was not declare in this scope

I verified the nunchuck.h and nunchuck.cpp files as shown on pages 574-576. I did not see an error. I have them stored in Libraries.

Here is the code copied from the book:

/*
* WiichuckSerial
* Uses Nunchuck Library discussed in recipe 16.5
* sends comma-seperated values for data
* Label string separated by commas can be used by receiving program
* to identify fields
*/


#include <Wire.h>
#include "Nunchuck.h"

// values to add to the sensor to get zero reading when centered
int offsetX, offsetY, offsetZ;

#include <Wire.h>
#include "Nunchuck.h"
void setup()
{
Serial.begin(57600);
nunchuckSetPowerpins();
nunchuckInit(); // send the intitialization handshake
nunchuckRead(); // ignore the first time
delay(50);
}
void loop()
{
nunchuckRead();
delay(6);
nunchuck_get_data();
boolean btnC = nunchuckGetValue(wii_btnC);
boolean btnZ = nunchuckGetValue(wii_btnZ);


if(btnC) {
offsetX = 127 - nunchuckGetValue(wii_accelX);
offsetY = 127 - nunchuckGetValue(wii_accelY);
}
Serial.print("Data,");
printAccel(nunchuckGetValue(wii_accelX),offsetX);
printAccel(nunchuckGetValue(wii_accelY),offsetY);
printButton(nunchuckGetValue(wii_btnZ));

Serial.println();
}

void printAccel(int value,int offset)
{
Serial.print(adjReading(value, 127-50, 127+50, offset));
Serial.print(",");
}

void printJoy(int value)
{
Serial.print(adjReading(value,0, 255, 0));
Serial.print(",");
}

void printButton(int value)
{
if( value != 0)
value = 127;
Serial.print(value,DEC);
Serial.print(",");
}

int adjReading( int value, int min, int max, int offset)
{
value = constrain(value + offset, min, max);
value = map(value, min, max, -127, 127);
return value;
}

Note from the Author or Editor:
In Recipe 4.11, delete the line:
nunchuck_get_data();

The download code has been updated.

Dennis Levenhagen  Mar 22, 2013  May 17, 2013
Printed, PDF, ePub
Page 174
11th line

Make the following change if you are using a 3.3V board:
const int referenceVolts = 3.3;

In the above sentence, the value of 3.3 is assigned to the referenceVolts which has a data type of int. However, the data type of the assigned value (in this case, 3.3) is not a int, but a float. So, the statement "const int referenceVolts = 3.3;" should be changed to the statement "const float referenceVolts = 3.3;"

Note from the Author or Editor:
In Recipe 5.9 on page 174, change the line:
const int referenceVolts = 3.3;
to:
const float referenceVolts = 3.3;

Soonbaek Yun  Sep 19, 2012  May 17, 2013
PDF
Page 177
Table 5-4

The combination of resistors used for max voltage of 30 is incorrect. Using a 1K and a 4K resistor would give a voltage reduction of 1/5, meaning that 6 volts would be applied to the analog pin, which can damage it.

Note from the Author or Editor:
In table 5-4, change the last row from:

4K (3.9K) 1K 1(4+1) 170
to:
5K (5.1K) 1K 1(5+1) 170

Andy Westrate  May 04, 2012  May 17, 2013
PDF
Page 177
4th Paragraph (Solution Section)

4th Paragraph (Solution Section)

The page text reads "For voltages up to 10 volts, you can use two 4.7K ohm resistors."

The table below then shows the resistor values of both resistors for voltages of up to 10 votls as 1k ohm.

I'm not sure whether it matters but wanted to check as it seems inconsistent.

Note from the Author or Editor:
Although two 4.7K resistors can be used in Recipe 5.11, for consistency with table 5-4, the text should be changed from:

"For voltages up to 10 volts, you can use two 4.7K ohm resistors."

to

"For voltages up to 10 volts, you can use two 1K ohm resistors."

Jonathan Sheppard  Jun 18, 2013 
Printed, PDF, ePub
Page 178
Code example: declaration and definition of resistorFactor

The code example "DisplayMoreThan5V" sketch gives a wrong voltage value.

The declaration and definition of resistorFactor says:

const float resistorFactor = 1023.0 / (R2/(R1 + R2));

This gives a wrong calculated voltage.

It should be:

const float resistorFactor = 1023.0 * (R2/(R1 + R2));

For example, for R1 = 1k (1000) and R2 = 1k (1000), R2/(R1 + R2) = 0.5. If you calculate the resistor factor based on the first definition above (by division), resistor factor becomes 2046. But it should be 511 (as in Table 5-4), which is given by the second definition above (by multiplication).


Note from the Author or Editor:
The download code for recipe 5.11 has been corrected.

in the solution sketch, change:
const float resistorFactor = 1023.0 / (R2/(R1 + R2));
to:
const float resistorFactor = 1023.0 * (R2/(R1 + R2));

tadatoshi  Mar 06, 2013  May 17, 2013
PDF
Page 195-196
algorithm used in example 6-5

in the sketch itself you have the line:

if( mV > INTERVAL * TABLE_ENTRIES-1 )

when discussing the sketch you have it written as:

if( mV > INTERVAL * TABLE_ENTRIES )


later in the sketch you have:

return distance[index] - ((distance[index] - distance[index+1]) * frac);

when discussing it you have it written:

return distance[index] + (distance[index]* (frac / interval));


...so in each case, which is correct??? i have my guess, but looking for some verification. thanks.

Note from the Author or Editor:
There are typos in the discussion for Recipe 6.5. The sketch listing in the book and the code download are correct.

on page 195 change:
if( mV > INTERVAL * TABLE_ENTRIES )
to:
if( mV > INTERVAL * TABLE_ENTRIES-1 )

change:
return distance[index] + (distance[index]* (frac / interval))
to:
return distance[index] - ((distance[index] - distance[index+1]) * frac);

nate  Jan 05, 2013  May 17, 2013
Printed, PDF, ePub
Page 225
Figure 6-17

In Figure 6-17, the Ground and +3.3V pins of the LY530AL breakout board are connected in reverse order to Arduino board. Negative voltage is applied to the gyroscope board.

Note from the Author or Editor:
In Figure 6-17 the connections to the ground and 3.3V pins should be swapped.

J.-F. Osselin  Nov 15, 2012  May 17, 2013
Printed
Page 265
code byte pins[] = .......

The pin array is typed as. byte. That made the NUMBER_OF_PINS formula confusing with regard of using sizeof(). When I referred back to pages 256 and 257, ledPins array is typed as an int. Then I grasped the need for the formula to calculate NbrLEDS using sizeof(). It seemed inconsistent to type the array differently on two code sections that are accomplishing the same thing. If the array is typed as a byte then determining the number of elements in the array becomes simpler ? I could be
Mistaken concerning this, but it did confuse me. Thanks

Note from the Author or Editor:
In Recipe 7.9, the solution code is correct and the technique for calculating array size works for any type. However, to avoid possible confusion, I have updated the download code with the pins array type changed from byte to int.

On page 265, change:
byte pins[] = {2,3,4}; // the pins that are connected to LEDs
to:
int pins[] = {2,3,4}; // the pins that are connected to LEDs

Randy Perkins  Apr 13, 2012  May 17, 2013
Printed, PDF, ePub
Page 270
2nd half of page

The 7 lines of code are repeated twice. Maybe if it was removed there would be room to include the 2nd half of the sketch on the next page. (271). This was hard to follow, especially with only a brief intro to interrupts. Overall I only mention tniscause I came to submit another erratta. Thanks

Note from the Author or Editor:
On page 270, remove the first occurrence of the following text:

#include <FrequencyTimer2.h>
byte pins[] = {2,3,4,5};
const int NUMBER_OF_PINS = sizeof(pins)/ sizeof(pins[0]);
const int NUMBER_OF_LEDS = NUMBER_OF_PINS * (NUMBER_OF_PINS-1);
byte pairs[NUMBER_OF_LEDS/2][2] = { {0,1}, {1,2}, {0,2} };
int ledStates = 0; //holds states for up to 15 LEDs
int refreshedLed; // the LED that gets refreshed
---

Randy Perkins  Apr 13, 2012  May 17, 2013
Printed, PDF, ePub
Page 272
const int segmentPins[8] .. middle of page

Arduino pin numbers for Segments G and F are reversed.
should read: const int segmentPins[8] = { 5,8,9,7,6,4,3,2};
Not sure what the numbers in the square boxes (fig 7-12) are for ?.
Maybe pin numbers for the 7-segment lcd, although no part number is given. Thanks

Note from the Author or Editor:
In the discussion sketch for Recipe 7.10 on page 272, change:
const int segmentPins[8] = { 5,9,8,7,6,4,3,2};
to
const int segmentPins[8] = { 5,8,9,7,6,4,3,2};

The download code has been corrected

Randy Perkins  Apr 13, 2012  May 17, 2013
Printed
Page 290
figure 8-1

Figure 8-1 is an illustration of the elements of a hobby servo motor. One of the elements is labeled 'gear reduction drive'. What is pictured will not operate as a gear reduction drive. The input and output shafts need to be reversed. As pictured this gear drive will provide increased rpm and lower torque at the output shaft, which is not what is needed in this application. Thanks

Note from the Author or Editor:
The illustration of a hobby servo in Figure 8-1 was drawn to feature the electronic elements, with just an impression of the gearing. However, for those need these details to be accurate, a new rendering of the gears will be used to illustrate future editions.

Enjoy.

Randy Perkins  Apr 26, 2012  May 17, 2013
Printed, PDF, , Other Digital Version
Page 307
Figure 8-10

Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3

directly above and to the left of the pin labeled 6

directly above and to the right of the pin labeled 11

directly above and to the left of the pin labeled 14

Note from the Author or Editor:
Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3
directly above and to the left of the pin labeled 6
directly above and to the right of the pin labeled 11
directly above and to the left of the pin labeled 14

The online parts list has has these parts correctly identified

Brian Jepson
Brian Jepson
 
Jun 01, 2012  May 17, 2013
, Printed, PDF, , Other Digital Version
Page 309
Figure 8-11

Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3

directly above and to the left of the pin labeled 6

Note from the Author or Editor:
Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3
directly above and to the left of the pin labeled 6

The online parts list has has these parts correctly identified

Brian Jepson
Brian Jepson
 
Jun 01, 2012  May 17, 2013
, Printed, PDF, , Other Digital Version
Page 311
Figure 8-12

Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3

directly above and to the left of the pin labeled 6

directly above and to the right of the pin labeled 11

directly above and to the left of the pin labeled 14

Note from the Author or Editor:
Please label the capacitors in the diagram as 0.1?f. The capacitors are located in the following places:

directly above and to the right of the pin labeled 3
directly above and to the left of the pin labeled 6
directly above and to the right of the pin labeled 11


The online parts list has has these parts correctly identified
directly above and to the left of the pin labeled 14

Brian Jepson
Brian Jepson
 
Jun 01, 2012  May 17, 2013
Printed, PDF, ePub, Mobi
Page 319
Description for Figure 8-16

Recipe 8.12 on Bipolar steppers has a typo in the label for the L298 H-bridge figure. The description for Figure 8-16 should be changed from:
Unipolar stepper with L298
to:
Bipolar stepper with L298

Michael Margolis
Michael Margolis
 
Jul 16, 2013 
Printed, PDF, ePub
Page 350
code fragment at the end of recipe 10.1

<code> Serial.println(results.value);</code>

causes compilation to fail with "'results' not defined in this scope" error, as 'results' is not defined in recipe 10.1.

Replacing 'results.value' with 'decodedSignal.value' fixes the problem.
Also, 'Serial.println' should be called after checking that the last signal was recieved at least 400ms ago, so the complete paragraph would be:


if (irrecv.decode(&decodedSignal) == true) //this is true if a message
//has been received
{
if (millis() - last > 250) { //has it been 1/4 sec since last message
lightState = !lightState; //toggle the LED
Serial.println(decodedSignal.value);
digitalWrite(ledPin, lightState);
}

Note from the Author or Editor:
in the code fragment at the end of Recipe 10.1 change :

if (irrecv.decode(&decodedSignal) == true) //this is true if a message has
// been received
{
Serial.println(results.value);// add this line to see decoded results

to:


if (irrecv.decode(&decodedSignal) == true) //this is true if a message

//has been received

{

if (millis() - last > 250) { //has it been 1/4 sec since last message
Serial.println(decodedSignal.value);

Thomas Amm  Apr 18, 2013  May 17, 2013
PDF
Page 364
Chapter 11.1 and figure 11-1

The information about wiring up an LCD seems to accurate however as simple and obvious as it seems, it never mentions soldering the wires/header to the LCD modules. Many newbies on the Arduino Forums are having issues with their LCDs not working and it is surprising how many are not soldering the wires to the LCD module and then hitting the forums asking for help about a non working LCD. It might be nice to stress this and mention it in the discussion section.

The other item worth noting is figure 11-1 while the pins and connections are correct, most 2 line LCDs out there don't number their pins in the order/direction as the LCD in figure.
When the LCD is looked at as shown with the holes at the bottom, they will be positioned towards the right of the module as shown; however, normally, pin 1 is on the right or closer to the edge of the module rather than closer to the center as show. Some newbies are blindly hooking up the wires as shown in the figure.
The result is that backlight lights up but nothing works.
It might be worth mentioning to people to verify the pin numbering and/or changing the diagram to match the more common 1602 type LCD modules.

--- bill

Note from the Author or Editor:
the text does say "It?s important to check the data sheet for your LCD to verify the pin connections. " but to reinforce the point, future editions should add a tip at the bottom of page 364 (above figure 11-1) as follows:

Most problem with LCDs are due to bad connections. Double check that the Arduino wires go to the correct LCD pins as these could be positioned or numbered differently from that shown in Figure 11-1. Also check that the wires or headers are properly soldered.

Bill Perry  Dec 13, 2012  May 17, 2013
Printed, PDF, ePub
Page 374
1st marquee function

There are 2 marquee functions on this page in the text, commentary in between the two functions suggests that the 2 functions will employ a different procedure to implement the scrolling text. Apparently the 1st function will employ lcd.scrollDisplayLeft() and the memory on the LCD, while the 2nd will use the Arduino's RAM to overcome the limitations on the LCDs memory.

The issue is that in the text both functions are exactly the same, without either using the lcd.scrollDisplayLeft().

Note from the Author or Editor:
The first sketch in the DIscussion of Recipe 11.4 incorrectly duplicates the sketch code at the end of the discussion. The correct Marquee code that begins on page 373 can be found in the download in the folder for Recipe 11.4A (ch11r4A.ino)

Replace the marquee function at the top of page 373 with this code:

// this function uses scrolling to display a message up to 32 bytes long
void marquee( char *text)
{
lcd.print(text);
delay(1000);
for (int position = 0; position < strlen(text)-numCols; position++)
{
lcd.scrollDisplayLeft();
delay(300);
}
}

Brian Slosman  Feb 17, 2013  May 17, 2013
Printed, PDF, ePub
Page 376
void loop() code

I think the sentence
"lcd.print(charCode);"
must be
"lcd.write(CharCode);".

Note from the Author or Editor:
Arduino release 1.0 and later changed the syntax for printing characters. The download code has been updated for Arduino 1.x as follows.

In the solution sketch for Recipe 11.5, change:
"lcd.print(charCode);"
to
"lcd.write(charCode);"

in the discussion text on page 377, change:
"... using the ASCII value in lcd.print."

to:

"... using the ASCII value in lcd.write."

Lutz Hoell  Feb 27, 2013  May 17, 2013
Printed, PDF, , Other Digital Version
Page 422
figure 13-1

Figure has SDA and SCL connections going to wrong I2C Master "Alog" pins (assuming the "I2C Master" is supposed to be an Arduino). The 1st paragraph correctly says what the connections should be.

Note from the Author or Editor:
The labels for Alog 4 and Alog 5 should be reversed in Figure 13-1 in the introduction to chapter 13:
change Alog 5 to Alog 4
change Alog 4 to Alog 5

The description and the figures in the recipes are correct.

David Williams  Mar 23, 2012  May 17, 2013
Printed
Page 429
code, in void setup and void loop

As stated on page 428, multiple BlinkM's should be connected to the 5v and GND line, not the Analog pins because they can only provide enough current for more than a couple of BlinkM's. Therefore, you don't have to turn on the analog pins for power in void setup. Also, in the void loop, you are setting address A (the first BlinkM) to two different colors without a delay. You never have set address C, so the third setColor should be set to address C, not address A.

Note from the Author or Editor:
The recipe (ch13r1A ) has been updated in the download.
On page 429 of the second edition, change:

void setup()
{
Wire.begin(); // set up Arduino I2C support
// turn on power pins for BlinkM
pinMode(17, OUTPUT); // pin 17 (analog out 4) provides +5V to BlinkM
digitalWrite(17, HIGH);
pinMode(16, OUTPUT); // pin 16 (analog out 3) provides Ground
digitalWrite(16, LOW);
}
void loop()
{
int brightness = 255; // 255 is maximum brightness
hueToRGB( color, brightness); // call function to convert hue to RGB
// write the RGB values to each BlinkM
setColor(addressA, R,G,B);
setColor(addressB, G,B,R);
setColor(addressA, B,R,G);

to:

void setup()
{
Wire.begin(); // set up Arduino I2C support
// BlinkM not powered through pins in this sketch
}


void loop()
{
int brightness = 255; // 255 is maximum brightness
hueToRGB (color, brightness); // call function to convert hue to RGB
// write the RGB values to each BlinkM
setColor(addressA, R,G,B);
setColor(addressB, G,B,R);
setColor(addressC, B,R,G);


Quin Etnyre  Apr 04, 2012  May 17, 2013
Printed
Page 475
Solution

This entire recipe contains contradicts itself as to which XBee is the transmitter and which is the receiver and which one in turn gets hooked up to the sensor and Arduino.

The Summary starts out identifying the transmitting XBee be hooked up to an analog sensor and the receiving XBee be connected to the Arduino.

Moving to page 476, the first clause of the first paragraph says "Wire up the transmitting XBee to the to the sensor, as shown in Figure14-7."

The caption for Figure 14-7, however, reads, "Connecting the receiving Series 2 XBee to an analog sensor."

The paragraph that follows starts with another contradiction: "Next, load the following sketch onto the Arduino, and wire the transmitting XBee to the Arduino..."

The same contradictions exist in the separate instructions for Series 1 XBees starting on page 477.

So lastly, what's the correct configuration?

Note from the Author or Editor:
The captions of Figure 14-7 and 14-8 should have the word "receiving' changed to "transmitting"



John Keller  Feb 25, 2013  May 17, 2013
Printed
Page 499
mid-page single-line code example starting "byte ip[]'

A comma is missing from an array initializer.

In the code example

byte ip[] = { 192, 168 1, 177 };

add a comma after the number 168.

Note from the Author or Editor:
The solution code in the book and in the download are correct so this recipe as published will compile and run without error. However, a comma is missing from the discussion text explaining the code -
change:
byte ip[] = { 192, 168 1, 177 };
to:
byte ip[] = { 192, 168, 1, 177 };

Kerry Veenstra  Feb 11, 2012  May 17, 2013
PDF
Page 505
5th paragraph

parseInt returns an integer value; if you want to get a floating-point value, use parseFloat instead:

float floatResult = client.parseInt();
Serial.println(floatResult);

In the first line of code, client.parseInt() function should be changed to parseFloat() function because we want to get a floating-point value. Right?

Note from the Author or Editor:
In Recipe 15.4 , the discussion text on page 505 should be changed from:
float floatResult = client.parseInt();
to
float floatResult = client.parseFloat();

Soonbaek Yun  Apr 18, 2012  May 17, 2013
Printed
Page 505
bottom paragraph

talks about a Google stock price and serial monitor in chp 7 but cant find any mention of it in chapter

Note from the Author or Editor:
The wording in the discussion of Recipe 15.4 is ambiguous. On page 505 change:

"...such as this example that gets the Google stock price from Google Finance and writes the value to analog output pin 3 (see Chapter 7) and to the Serial Monitor:"

to:

"...such as this example that gets the Google stock price from Google Finance and writes the value to analog output pin 3 and to the Serial Monitor. ( See Chapter 7 if you want to read about using analog output pins)"

Ken Kremer  Jun 12, 2012  May 17, 2013
Printed, PDF, , Other Digital Version
Page 550
Code for Recipes 15.15 and 15.16

Recent Pachube feed IDs exceed the size of an Arduino int, therefore the variable type should be changed from:
const int feedID
to:
const unsigned long feedID

The download code for these recipes has been updated.

Michael Margolis
Michael Margolis
 
Jan 15, 2012  May 17, 2013
Printed, PDF, ePub
Page 622
China

const long precision = (1000000/(F_CPU/1000)) * prescale ;

The above does not evaluate correctly. The real answer should be 500 nanoseconds but it returns 496 with a prescaler of 8.

This is because the division of (1000000/(F_CPU/1000)) is 62.5 and because we are using integers it rounds down to 62.


By the way, I have tried to use the code and it does not work. The time returned is too small.

pulses are sampled while LED is lit
500 microseconds per tick
Durations in Microseconds are:
20505
20505
20505
20504
The input is a 2Hz square wave.


Note from the Author or Editor:
The download code has been corrected. The Solution sketch for Recipe 18.8 on pages 621-623 should be updated with the code in CH18r8.ino in the download.

Anonymous  Dec 20, 2012  May 17, 2013
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 644
United States

Figure B-1 refers to transistor TIP102. It should be TIP120.

Note from the Author or Editor:
The TIP102 is often used instead of a TIP120.
To avoid confusion, the text on page 647 should be changed from:
The TIP120 transistor is a popular choice ...
to:
The TIP120 transistor or the more recent TIP102 are popular choices ..

Puneet Lamba  Nov 03, 2013 
Printed, PDF, ePub
Page 646
Last part of Figure B4

The figure says that you should use a short wire to also connect this to the center leg. True, but not connection is shown.

Note from the Author or Editor:
The wire connecting the pot center and left leg is missing.

Anonymous  Jan 27, 2013  May 17, 2013
Printed, PDF, ePub
Page 653
Using Snubber Diodes with Inductive Loads

Incorrect reference: Snubber diodes are used to prevent that by conducting
the voltage spikes to ground. Figure A-1 in Appendix A shows an example of a snubber
diode used to suppress voltage spikes when driving a motor.

Figure A-1 in Appendix A should corrected to read Figure B-1 in Appendix B.

Note from the Author or Editor:
In Appendix C page 653, the reference to Figure A-1 in Appendix A should read:
Figure B-1 in Appendix B

Mike Logan  Jul 22, 2012  May 17, 2013
Printed, PDF, , Other Digital Version
Page 663
2nd paragraph

The ?Port? column lists the physical port used for the pin?see Recipe 18.11 for information
on how to set a pin by writing directly to a port. The introduction to Chapter
18 contains more details on timer usage. The table shows:
? USART RX is hardware serial receive
? USART RX is hardware serial transmit

In the last line, the string "USART RX" should be changed to "USART TX."

Note from the Author or Editor:
The table is correct, however the text in bullet points above the table should be changed from:
? USART RX is hardware serial transmit
to:
? USART TX is hardware serial transmit

Soonbaek Yun  Jun 09, 2012  May 17, 2013