12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
- #include "a110x.h"
-
- using namespace std;
-
- int shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
-
- int main ()
- {
- signal(SIGINT, sig_handler);
-
-
-
- upm::A110X* hall = new upm::A110X(2);
-
-
-
- while (shouldRun)
- {
- bool val = hall->magnetDetected();
- if (val)
- cout << "Magnet (south polarity) detected." << endl;
- else
- cout << "No magnet detected." << endl;
-
- sleep(1);
- }
-
-
- cout << "Exiting..." << endl;
-
- delete hall;
- return 0;
- }
|