Project 14: Tweak the arduino logo || Weird values


I am getting weird vlaues from my potentiometer.

This is my code:

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

And the processing code:

import processing.serial.*;
Serial myPort;
PImage logo;
int bgcolor = 0;
void setup(){
  colorMode(HSB, 255);
  logo = loadImage("");
  size(170, 116);
  println("Avaliable serial ports:");
  myPort = new Serial(this, Serial.list()[0], 9600);
void draw(){
  if (myPort.available() > 0) {
    bgcolor =;
  background(bgcolor, 255, 255);
  image(logo, 0, 0);

I couldn't get logo.width and logo.height to work, so i just used 170 and 116.

The Arduino logo shows up but it stays red.


Update Arduino code : Present Serial.write(analogRead(A0)/4);

Change: Serial.print(analogRead(A0)/4); OR Serial.println(analogRead(A0)/4);

Should solve the problem.

Update the following lines of code in the processing code and the logo.width and logo.height will also work.

logo = loadImage(""); size(logo.width, logo.height);

this can be a temporary fix for you i guess.

just change this

myport= new Serial(this, Serial.list()[0], 9600);

the number 0, change it to the right port that your arduino is connected. It didnt worked for me when it was 0, then i changed to 3(arduino was on COM3) didnt work either, 2 didnt work and 1 was the right one.

I had the same issue than you, using Processing 3.

The solution is to use the "while" keyword instead of "if" in the draw() function :

while (myPort.available() > 0) { bgcolor =; println(bgcolor); }