Help! Arduino Project 14 not working

So I have been trying to get project 14 working on the Arduino. However, the logo just changes colors wildly, and takes no input from the Arduino - when I take out the white knob, it does nothing for the program. The code is correct- I typed it twice; I used the processing code both from the website with Processing 3.2.3 and from my more outdated Aruduino book with Processing 1.5.1. Each time, it did the same thing - values appeared in the console on Processing, but the values were random, and not connected to the Arduino. The color change on the logo matched those values.

If it makes a difference, I loaded the image from my desktop (I did save it in sketches in Processing) and not the web, since the computer I was using was not connected to the internet. Also, I did used this tutorial: https://forum.arduino.cc/index.php?topic=415066.0 to get rid of an error on Processing 3.2.3. Still, it did not work!

Can someone please help me?!

You're going to have to help us out here - what is project 14? Maybe post some code (in code tags)?

Sorry - I assumed all the Arduino boards had the same workbook. I have the Arduino Uno. Project 14 is "Tweak the Arudino Logo." The goal of the project is to turn the potentiometer (connected to A0)on the breadboard and change the color on the sketch of the Arduino logo on Processing. I don't know if you had used that- it's needed for this project in my workbook, but I don't know about other Arduini.

The arduino code is pretty simple: void setup() { Serial.begin(9600); } void loop() { Serial.write(analogRead(A0)/4); delay(1); } The Processing code (I'm including the one that is for Processing 1.5.1) is this: import processing.serial.*; Serial myPort; PImage logo; int bgcolor = 0; void setup() { colorMode(HSB, 255); logo = loadImage("arduino_logo.png"); size(logo.width, logo.height); println("Available 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, 255, 255); image (logo, 0, 0); }

on running the serial port list follow those instructions closely to add serial port number to processing sketch and get the http image also otherwise code is good

lenringumi: I assumed all the Arduino boards had the same workbook

The same workbook? None of mine came with any workbook.

values appeared in the console on Processing, but the values were random, and not connected to the Arduino.

Sounds like you have not wired the pot up to the Arduino correctly and the analogue input is not connected to anything. This condition is said to be a "floating input" and will produce random numbers due to pick up of interference signals.

rogertee: on running the serial port list follow those instructions closely to add serial port number to processing sketch and get the http image also otherwise code is good

I'm not sure what you mean exactly. My arduino was connected to COM4, and in the list COM4 was [1], so I plugged that into the code.

Grumpy_Mike: Sounds like you have not wired the pot up to the Arduino correctly

I just checked my wiring again; it is the same as in the book, except that the pot is straddling the middle of the breadboard (with the A0 wire then on the other side with the single-pin side of the pot). This seemed to make no difference in my other projects. Still I tried putting all the wires and the pot on one side; it made no difference. Other than that there is no difference between my breadboard and the example in the book.

manor_royal: The same workbook? None of mine came with any workbook.

I guess you had to get it with a kit. My school bought I bunch of starter kits and I just got one on loan in my computer programming class.

Hi, Remove the pot, and wire the A0 to gnd, see what happens, then remove the wire and connect A0 to 5V.

Can you post a picture of your project so we can see your layout, also if possible a picture of the circuit in the book?

Thanks.. Tom... :)

Show us a photo of that pot wiring, it sounds very wrong. Your problem is that pot, write a small sketch to output the pot reading to the serial port and view it in the serial plotter. You will find out if it works or not.
This action is known as fault finding.

So here is my fault-finding program, which I edited from a previous arduino sketch, since we are doing this in school as an introductory project to coding, I don't really know how to code yet.

int const potPin = A0; int potVal; void setup() { Serial.begin(9600); } void loop() { potVal = analogRead(potPin); Serial.print("potVal: "); Serial.print(potVal); delay(3); } The pot seemed to work, at least if my program is correct. When I turned the knob, the values changed, and when I left it alone, the values stayed constant.

TomGeorge: Remove the pot, and wire the A0 to gnd, see what happens, then remove the wire and connect A0 to 5V.

So I tried this, and when I connected A0 to GND, the values in my fault finding program (which I wrote above) fluctuated around 918. When I tried this by wiring A0 to 5V, the values fluctuated around 230 - though first, when I opened the serial monitor, it went to 359 and then down to 230. I kept A0 connected to 5V, and tried using my fault-finding program in conjunction with the Processing sketch. The values for the image fluctuated around 50, in time with the delay of (3000) which I set to test if it was communicating, which seems at least more consistent than with the pot, even though we were supposed to use Serial.write, and the fault-finding program uses Serial.print. I thought maybe that means that Serial.print can work with processing (perhaps I interpreted the results of the previous test incorrectly, though), so I used my fault finding program, while it was connected to the pot, with the processing sketch. But the colors changed wildly again.

Here is a picture of my wiring: https://drive.google.com/open?id=0B2plCtVK56RAY3pNQVJQdmZ0YkE Here is what the wiring is supposed to look like : https://www.arduino.cc/en/ArduinoStarterKit/Prj14

Thank you for your help.

That is good, I would have replaced:-

Serial.print("potVal: ");
Serial.print(potVal);

with just

Serial.println(potVal);

So you get one number on one line.

You might want to read this How to use this forum to see how to post code in tags and how to attach pictures.

It looks like you are doing everything correctly however the results of those two tests are not consistent. The first where you have the pot is correct, however the second where you wire A0 to 5V and ground is not what you should see. You should see a solid value of zero when connected to ground and a solid constant value of 1023 when it is connected to 5V.

To me this suggests that your bread board, or pins into the socket on the Arduino, is not making a solid consistent contact.

You can find project 14 here:

p.14.JPG

I will take a minute and look at it to give you feedback

oid setup() {
  // initialize serial communication
  Serial.begin(9600);
}

void loop() {
  // read the value of A0, divide by 4 and
  // send it as a byte over the serial connection
  Serial.write(analogRead(A0) / 4); ///                           ­
  delay(1);
}

If you put no voltage on the Analogue 0 (A0) pin, the data sent to Serial will be a random number and Processing will work with random numbers on the Arduino logo.

I suggest you put a resistor(fixed or variable) on A0, like a Pot or and Photorésistance

Then you must copy this:

// import the serial library
import processing.serial.*;

// create an instance of the serial library
Serial myPort;

// create an instance of PImage
PImage logo;

// a variable to hold the background color
int bgcolor = 0;

void setup() {
  size(1, 1);
  surface.setResizable(true);
  // set the color mode to Hue/Saturation/Brightness
  colorMode(HSB, 255);

  // load the Arduino logo into the PImage instance
  logo = loadImage("http://www.arduino.cc/arduino_logo.png");

  // make the window the same size as the image
  surface.setSize(logo.width, logo.height);

  // print a list of available serial ports to the
  // Processing staus window
  println("Available serial ports:");
  println(Serial.list());

  // Tell the serial object the information it needs to communicate
  // with the Arduno. Change Serial.list()[0] to the correct
  // port corresponding to your Arduino board.  The last
  // parameter (e.g. 9600) is the speed of the communication.  It
  // has to correspond to the value passed to Serial.begin() in your
  // Arduino sketch.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // If you know the name of the port used by the Arduino board, you
  // can specify it directly like this.
  // port = new Serial(this, "COM1", 9600);
}

void draw() {

  // if there is information in the serial port
  if ( myPort.available() > 0) {
    // read the value and store it in a variable
    bgcolor = myPort.read();

    // print the value to the status window
    println(bgcolor);
  }

  // Draw the background. the variable bgcolor
  // contains the Hue, determined by the value
  // from the serial port
  background(bgcolor, 255, 255);

  // draw the Arduino logo
  image(logo, 0, 0);
}

In a new sketch in Processing. You can download a fresh copy from here: https://processing.org/download/

Welll that is about it. Take care mate.

@Frédéric_Plante Can you address the problem the OP is facing and not try and boost your ego. Try and be helpful and suggest something he can do to get his circuit working. I know it goes against the grain for you but try please.

If you put no charge on the Analogue 0 (A0) pin, the data sent to Serial will be a random number

I know you suffer the handicap of being French but the word is "voltage" not charge.

Keep it civil. FredericPlant is currently enjoying a short forum timeout for egregious personal abuse.

Frédéric_Plante: Ah ah ! as usual, older member tend to loose touch with reality. I invite the older member to get back in touch with the basis, caus it getting ridiculous. MdR

sp."As usual, older members tend to lose touch with reality [sic]. I invite the older members to get back in touch with the basics, because it is getting ridiculous".

You're welcome.