Project 14 [tweak the arduino logo]

when I start doing the project 14 I have faced a problem, after I have wrote my codes therewas an error in the processing program say as the Pic .
so what I should do ?

These codes should work without error.

Arduino Code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(analogRead(A0)/4);
  delay(100);
}

Processing code:

import processing.serial.*;
Serial myPort;
PImage logo;
int bgcolor = 0;
void setup(){
  colorMode(HSB, 255);
  logo = loadImage("https://www.arduino.cc/en/pub/skins/arduinoWide/img/logo.png");
  size(logo.width, logo.height);
  println("Avaliable serial ports:");
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw(){
  if (myPort.available() > 0) {
    bgcolor = myPort.read();
    println(bgcolor);
  }
  background(bgcolor, bgcolor, 255);
  image(logo, 0, 0);
}

here :

size(logo.width, logo.height);

use numbers instead of variables, like the error says, like

size(200, 100);

I've just tried it yesterday. Besides the size that "RajoAlfa" mentioned above.
Please modify this line as well:
myPort = new Serial(this, Serial.list()[0], 9600);
to
myPort = new Serial(this, "COM3", 9600);

Note: COM3 is what my Arduino using.

It works for me!! :slight_smile:

I am using OS X 10.11.1.

The code the book presented didn't work for me. This is a summary of the changes I made so that it worked.

Arduino code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.write(analogRead(A0)/4);
  delay(100);
}

Processing code:

import processing.serial.*;
Serial myPort;
PImage logo;
int bgcolor = 0;
void setup(){
  colorMode(HSB, 255);
  logo = loadImage("https://www.arduino.cc/en/pub/skins/arduinoWide/img/logo.png");
  size(400, 200);
  println("Avaliable serial ports:");
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[1], 9600);
  
}
void draw(){
  if (myPort.available() > 0) {
    bgcolor = myPort.read();
    println(bgcolor);
  }
  background(bgcolor, bgcolor, 255);
  image(logo, 0, 0);
}

In Arduino code:

  1. delay(1) to delay(100)

Processing code:

  1. change image url
    https://www.arduino.cc/en/pub/skins/arduinoWide/img/logo.png

  2. change size() to constants
    size(400, 200);

  3. change myPort
    myPort = new Serial(this, Serial.list()[1], 9600);