March 2008

Error in the Cat Graphing example

In the cat graphing example in chapter 3 as published in the book, the comments say:

// if the sensor value is less than the threshold,
// and the previous value was greater, then the cat
// just left the mat
if (prevSensorValue >= threshold) {
   catOnMat = false;
}

According to the second comment, the condition should be “greater,” but actual code is “greater or equal.”

The comment is right and the code should be as follows:

// if the sensor value is less than the threshold,
// and the previous value was greater, then the cat
// just left the mat
if (prevSensorValue > threshold) {
   catOnMat = false;
}

Thanks to Shigeru Kobayashi for catching this.

Chapter 3
Errata

Comments (0)

Permalink

Comment error in simple serial code

In the Chapter 1 Simple Serial code as published in the book says:

// after a quarter of a second, turn the LED on:

It should say

// after a half of a second, turn the LED on:

Thanks to Shigeru Kobayashi for catching it.

Chapter 1
Errata

Comments (0)

Permalink

Xport Pong Emulator

This Processing sketch sends the same bytes as the Xport that’s configured for the networked Pong game in Chapter 5. It’s a handy way to connect a microcontroller to the server when you don’t have an Xport, or aren’t sure your Xport is working.

Continue Reading »

Chapter 5
etech2008
Processing
Updates

Comments Off

Permalink

Analog Output

/*
 Analog output
 Language: Wiring/Arduino

 Reads an analog input and uses its value to dim an LED output
 Connections:
 analog sensor on analog input pins 0
 LED on digital pin 3
 */

Continue Reading »

Arduino/Wiring
etech2008

Comments Off

Permalink

Simple Sensor Reader

This program reads two analog sensors and one digital sensor and prints them out. Use it for testing your sensors.

Continue Reading »

Arduino/Wiring
etech2008

Comments Off

Permalink

Reading a Switch

This program reads a switch (i.e. a digital input) and changes an LED only when the switch changes from off to on. You can modify it to count switch presses as well. There’s a digital input connected to Digital I/O pin 2, and an LED attached to digital I/O pin 3. I refer to this method of detecting when the switch has changed as edge detection on a switch

Continue Reading »

etech2008

Comments Off

Permalink