|
- #include <Bounce.h>
-
-
-
- const uint8_t ORIENTATION_PIN = 16;
-
- Bounce orientation = Bounce( ORIENTATION_PIN, 50 );
-
- int awake;
-
- void setup() {
-
- pinMode( ORIENTATION_PIN, INPUT );
- digitalWrite( ORIENTATION_PIN, HIGH );
-
- Serial.begin(19200);
- Serial.println( "Orientation Test " );
- Serial.println();
-
- awake = orientation.read();
-
- Serial.println( awake ? "Awake!" : "Asleep!" );
-
- }
-
- unsigned long lastKnock = 0;
-
- void loop() {
-
- orientation.update();
-
-
- if ( orientation.read() != awake && orientation.duration() > 500 ) {
-
- awake = orientation.read();
-
- if ( awake ) {
-
- Serial.println( "Waking Up!" );
-
-
- }
- else {
-
- Serial.println( "Falling Asleep" );
-
-
- }
- }
-
- }
|