Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mraa.hpp"
- #include <unistd.h>
- int main() {
- mraa::Aio *a0;
- uint16_t value;
- bool flag = false;
- bool on = false;
- a0 = new mraa::Aio(0);
- if (a0 = NULL) {
- return MRAA_ERROR_UNSPECIFIED;
- }
- while(true) {
- value = a0->read();
- if (value) {
- if (!on) {
- on = true;
- system("cd ~/NodeP1 && node index.js");
- flag = true;
- } else if (flag == false) {
- system("shutdown -h 0");
- }
- } else {
- if (flag == true)
- flag = !flag;
- }
- sleep(3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement