Help with Triangle demo app in Making Things Talk

I’m brand new to this, and reading thru the “Making things talk” book.
I downloaded arduino-0016, and stuck on Chapter 1 Triangle app.

Even if I copy/paste the sample code from this site, I get the error: "In function 'void setup(): error: ‘size’ was not declared in this scope In function ‘void draw()’.

What could I be doing wrong?

/*
Triangle drawing program
Language: Processing
Draws a triangle whenever the mouse button is not pressed.
Erases when the mouse button is pressed.
*/

// declare your variables:
float redValue = 0; // variable to hold the red color
float greenValue = 0; // variable to hold the green color
float blueValue = 0; // variable to hold the blue color

// the setup() method runs once at the beginning of the program:

void setup() {

background(0); // sets the background of the window to black
fill(0); // sets the color to fill shapes with (0 = black)
smooth(); // draw with antialiased edges
}

// the draw() method runs repeatedly, as long as the applet window
// is open. It refreshes the window, and anything else you program
// it to do:

void draw() {

// Pick random colors for red, green, and blue:
redValue = random(255);
greenValue = random(255);
blueValue = random(255);

// set the line color:
stroke(redValue, greenValue, blueValue);

// draw when the mouse is up (to hell with conventions):
if (mousePressed == false) {
// draw a triangle:
triangle(mouseX, mouseY, width/2, height/2,pmouseX, pmouseY);
}
// erase when the mouse is down:
else {
background(0);
fill(0);
}
}

Either you're missing a library that goes with the book or you're only using the errata code rather than the complete code.

  • Brian

Sorry ... my posted example code left out the command that was causing the issue in the setup() function.... size(320, 240);

I also see no reference to any additional library for the book examples. I understand that the size() command is a built in command to the language.

Here is a much simpler sample code that causes the same error in my environment. Shouldn't this simple example compile without error.

void setup() { size(320, 240); // sets the size of the applet window }

I understand that the size() command is a built in command to the language.

No, it is not. Which is why I offered this suggestion...

Either you're missing a library that goes with the book or you're only using the errata code rather than the complete code.

  • Brian

the code you posted looks awfully familiar to processing code... are you sure its meant for the arduino IDE and not for the processing IDE

(the size function, for example, is directly from the standard processing library)...

find out more here, if you wish: www.processing.org

From the original message...

Language: Processing

Good catch, jezuz!

Coding Badly skulks away to get the egg off his face...

I hadn't made the distinction between the 2 different IDE's. I pulled down Processing IDE and the triangle sample code works just fine.

Thanks for clearing this up - Jak