Executing a Processing Script from Arduino Uno

Hi guys,

Having spent sometime learning from tutorials and exploring library examples, I am left scratching my head figuring out the following:

I want to shutdown Windows 10 from an Arduino UNO via a button push connected to the Arduino.

I have a script using Processing that shuts down windows which I found from another online forum. A simple run of the script achieves the desired result of shutting down Windows.

I require a script for the Arduino that would run the Processing sketch via serial communication after a button is pushed. Whilst I appreciate the concepts involved and have experimented with serial communication between Arduino and Processing, I am having difficulty going further. Any help would be greatly welcome.

The Processing sketch for shutting down Windows I found, is pasted below and works as required, but no doubt requires some editing to have it read a command from the Arduino button push.

void setup() { killBill(); }

void killBill() { try { Runtime.getRuntime().exec("shutdown.exe -s -f -t 0"); } catch (IOException e) { e.printStackTrace(); } }

Hi, first of all a pedantic note about using code tags in posts. With that out of the way, two solutions come to mind: when you press the button connected to the Arduino, it sends a particular string to the Processing script (e.g. a simple 'K' character). The Processing script keeps waiting for the 'K' string to be sent. When it received that, it executes the shutdown command.

Another alternative could be the Arduino sending full commands to the Processing script, which would simply receive and execute the strings sent by Arduino.

Hope this helps.

Hi,

Thank you for the reply, and apologies for my etiquette faux pas!

Yes, either one of the suggestions would be suitable for my requirement. Your first example, the button press sends a "K" command and executes the shutdown sounds simple, and would no doubt require some tweaking of the Processor code, and obviously the Arduino code. Whilst I am playing catch up with the programming side, I would greatly appreciate some guidance on what the script would entail, or pointing in the right direction so I can code myself.

Kind regards.

Hi, have a look at some examples in processing about how to read a string from the serial port.

As for Arduino, issue a Serial.println("K") whenever you detect the button has been pressed.

Feel free to post any code snippets here or other questions. :)

  1. So far I know about the Serial Monitor of Arduino:
    (a) It receives message from Arduino Kit and displays in the windows.
    (b) It takes command from the users and sends to the Arduino Borad.

  2. There is no way you can read the command that is coming from the Arduino Board.

  3. I think that you need to develop a separate GUI (Similar to the image given below) which will
    communicate with the Arduino.

  4. If you know Visual Studio Programming, the attached file may help you to develop the GUI.
    !(亚洲2020天天堂在线观看,亚洲欧洲自拍图片专区,日韩亚洲视频一区二区三区,国产亚洲欧洲日韩在线三区(Win7-VC# based GUI for 8051))

ICAEE13(Win7-VC# based GUI for 8051).pdf (433 KB)

There is no way you can read the command that is coming from the Arduino Board.

Wrong. Use the Arduino Serial output as a serial input to Processing.