Hi. Firstly, huge apologies if this is in the wrong section - I'm new to processing, and afaik this is just an issue with the script itself rather than any of the other little dos scripts or arduino code it's calling.
I'm currently working on a project for Maker Faire, building a phrenology cabinet that runs a print job. I have a processing script running from arduino which calls a simple print script command through Irfanview on a button press - open("c:/print.cmd");. The print script works perfectly from processing by itself, and the arduino script works fine independently too, but when I use it all together the print doesn't run until I close the sketch. The ellipse is just for visual testing, and it also works perfectly. As the cabinet will be used for the full day, resetting the code after every use is not viable.
Is there something stupid and blindingly obvious I'm missing in the code? (I'm really a complete beginner here, so that's a huge possibility), or is there a way to 'nest' this script within another, use an exit function to quit this script and an open function to run it again? Or any other solutions anyone might have? I've been searching, and not finding any answers..
Huge thanks.
Code:
import processing.serial.*;
Serial port;
float button = 0;
boolean buttonOn = false;
void setup()
{
size(500,500);
port = new Serial(this, Serial.list()[3], 9600);
port.bufferUntil('\n');
smooth();
}
void draw()
{
background(0);
ellipseMode(CENTER);
ellipse(250,250,250,250);
stroke(255);
fill(button*255);
}
void serialEvent (Serial port)
{
button = float(port.readStringUntil('\n'));
if(button == 1 && ! buttonOn) {
open("c:/print.cmd");
println("Someone pressed the button and I'll do something");
buttonOn = true;
}
if(button == 0 && buttonOn) {
println("Someone released the button and I'll do somethingelse");
Hi. 1st time poster so apologies if this is in the wrong section.
I'm working on a piece with an arduino. On a switch press, I want a usb printer to print a single dot on a page (I'll have the images I want preprinted on the paper - all I really want to do is have the printer feed the page, but it has no feed button and printing a dot seemed to be the easiest solution). I'm a total noob here, and have been searching for days now without joy. All the code I've found seems to relate to serial or thermal printers. Can someone clarify if it's even possible to control a USB inkjet printer? I have a Win XP SP2 machine for the project (has to be an older one as it's gonna stay in the gallery with the piece), and I'm working with an Arduino Uno, if that makes any difference.
Any help at all on where to start even would be hugely appreciated.