====== Arduino code calling a Python script ====== #include #include 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()); //} }