Hi all
First of all - new to the Arduino (only experience is with the first 14 projects in this book) - foreign (danish) so sorry about language issues - new to this forum (so sorry if the answer is already out there, but I spent about 3 hours reading through old posts and found nothing that relates to my problem).
So when I run the processing program - it reads the myPort, and sets a background color. GREAT! But then when I turn the potentiometer nothing happens. If I leave it at another setting stop the program, and run it again - it reads the new setting of myPort and sets the background color according. But still no change in realtime - meaning nothing changes when I turn the potentiometer.
I checked the read of myPort and there is no change. I checked the serialmonitor in the Arduino-part, and it changes when I turn the potentiometer.
I triple checked both codes, and I cannot find any issues. I double checked the wiring, and there should be nothing wrong there.
This is my last try - so PLEASE HELP ME - before I mark this project down as a failure!!
You are assuming that we all know what book you have and are familiar with its contents. I doubt there are many if any people here who know anything about the book you have.
You have no loop() function, that's never going to work.
You mention a potentiometer, which suggests that you have one wired to an analogue port. There is nothing in your code that I can see that reads an analogue port.
Please post a schematic showing how you have it wired up, and maybe some photos.
++Karma; // For posting your code correctly on your first post.
PerryBebbington:
You have no loop() function, that's never going to work.
You mention a potentiometer, which suggests that you have one wired to an analogue port. There is nothing in your code that I can see that reads an analogue port.
It's the processing sketch, not an Arduino sketch. (processing has setup(), but draw() not loop().)
There is presumably a separate Arduino sketch that reads the pot and Serial.print()s that for processing's myPort.read() to pick up.
There is presumably a separate Arduino sketch that reads the pot and Serial.print()s that for processing's myPort.read() to pick up.
Oldfmo, if that's the case then we need to see it and see how you have it wired. For clarity, how YOU have it wired, not how the books says it should be wired.
Don't know how relevant it is but I notice in the original project there was a delay(33) after the Serial.write() which you've reduced to a very short delay(1). Have you tried it with the original value?
@Slipstick:::
You are soooo correct.
I was working from the paperback book that came with a projectbox, and in the code it says delay(1);, but changing it to delay(33) made all the difference.
THANK YOU SO MUCH - NOW IT WORKS!!!
Off course now I feel a bit silly, seeing as I should have caught that one myself
I had just typed this when I saw that you have it sorted....
FWIW it works for me, copied straight from that link with no changes, straight out the box.
The background colour changes, and the processing "serial monitor" or whatever they call the space at the bottom of the processing ide prints the varying value on the fly.