Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Process.h>
- // set pin numbers:
- const int buttonPin = 2; // the number of the pushbutton pin
- const int redPin = 3; // the number of the red LED
- const int greenPin = 4; // the number of the green LED
- const int ledPin = 13; // the number of the LED pin
- // variables will change:
- int buttonState = 0; // variable for reading the pushbutton status
- void setup() {
- // initialize the LED pin as an output:
- pinMode(ledPin, OUTPUT);
- pinMode(redPin, OUTPUT);
- pinMode(greenPin, OUTPUT);
- // initialize the pushbutton pin as an input:
- pinMode(buttonPin, INPUT);
- //Initialize Bridge
- Bridge.begin();
- //Initialize Serial
- Serial.begin(9600);
- //Wait until a Serial Monitor is connected.
- while (!Serial);
- //
- }
- void loop() {
- // read the state of the pushbutton value:
- buttonState = digitalRead(buttonPin);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(ledPin, HIGH);
- Process p;
- p.runShellCommand("/root/run.sh");
- // turn on some LED
- while(p.running());
- //
- Serial.print(p.exitValue());
- if(p.exitValue() == 0) {
- Serial.print("Sucess");
- digitalWrite(greenPin, HIGH);
- } else {
- Serial.print("Fail Whale");
- digitalWrite(redPin, HIGH);
- }
- } else {
- digitalWrite(ledPin, LOW);
- }
- /*
- // Print command output on the Serial.
- // A process output can be read with the stream methods
- while (p.available() > 0) {
- char c = p.read();
- Serial.print(c);
- }
- // Ensure the last bit of data is sent.
- Serial.flush();
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement