Warning: Use of undefined constant PREG_PATTERN_VALID_LANGUAGE - assumed 'PREG_PATTERN_VALID_LANGUAGE' (this will throw an Error in a future version of PHP) in
/var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line
633
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in
/var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line
633
Arduino code calling a Python script
#include <FileIO.h>
#include <Process.h>
void setup() {
// Initialize Bridge
Bridge.begin();
// Initialize Serial
Serial.begin(9600);
//
// // Wait until a Serial Monitor is connected.
while (!Serial);
Serial.println("pythonic");
FileSystem.begin();
runPaj();
}
void loop() {
// execute the script every (1)seconds
// runPaj();
// delay(1000);
//no need to do that if the script is running in a loop and it only closes the port when it is stopped
}
void runPaj() {
Process p;
p.begin("python");
p.addParameter("/mnt/sd/arduino/www/python-test.py");
//p.addParameter("foo"); // A command line parameter for the script
p.addParameter("&2>1"); // pipe error output to stdout
p.run(); // blocking call to run python; ATMega execution halts until complete
//while(p.available()>0) {
// Console.print(p.read());
//}
}