i'm working on a processing sketch which is activated by an emergency button connected to arduino. Arduino is loaded with a standard firmata and the button is quite similar to the one in the picture. Its mechanism is quite simple: it connects two wires and close their circuit by default; on press (and for the whole time it is pressed) the circuit opens. Sadly i'm very poorly skilled in both coding and electronics and it took me a while to understand that, because of the capacity of the wires (1m long, thick copper wires), i couldn't use a "arduino.digitalRead()" function to understand when the button was pressed (and the circuit opened) because there was always a small voltage reaching the pin.
So I connected the button on one side to 5v and the other to an analog pin and used an arduino.analogRead() to check when there was a decreasing in the circuit capacity and understand the button was pressed.
void draw() {
if ( (arduino.analogRead(pinBottone) < 800) && (animazione.activated == false)) {
delay(100);
animazione.activated = true;
immagine.update();
}
For a while everything seemed working, but then I realized that sometimes there was some sort of interruption in the communication with the receiving analog pin.
If I quickly double press the button the animation starts, but
the value received from arduino.analogRead() gets stuck and stops changing, making the button useless until I restart the sketch. I made sure it wasn't a problem with the button and tried changing the analog pin. Deleting the "anti-buttonmashing" var called "animazione.activated" from the sketch, somehow, makes it work a little better, but the crash still occurs.
I came to a dead point where I really don't know where to look to find an explanation for the phenomenon and a possible fix for it.
If you think it's worthy I can post the whole sketch, but I'm still getting used to object-oriented programming and by now it may look like some kind of a long long spaghetti coding.
I checked any source on the internet and coudln't find any way of communication between processing and a printer. Does anybody have any idea about it, any solution or any suggestion to where i can direct my research?
I'm working on a personal project which requires the printing of a graphical output but since my coding skills are pretty limitedt i wouldn't prefer to get into cocoa or something like that! :)
Hello everybody, i'm trying to work with PGraphics, but something keeps getting wrong. The problem that i can't understand is why processing draws on the screen everything between beginDraw() and endDraw(), but doesn't draw anything when i call the picture back with image(pic, x, y).
It seemed so easy in the beginning but i already wasted 3 nights looking for bugs in my code or common problems in the internet.
Thank you in advance!