TriOmega
Published

Dryer Notifier

A small device that can be put on a dryer to give a notification when the dryer has finished.

BeginnerShowcase (no instructions)40
Dryer Notifier

Story

Read more

Code

DryerNotification.ino

Arduino
#include <Adafruit_CircuitPlayground.h>

float X, Y;
int noMotionStreak = 0;

void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
  CircuitPlayground.setAccelRange(LIS3DH_RANGE_2_G);
  pinMode(A1, INPUT_PULLUP);
}

void loop() {

  if (! digitalRead(A1)) {                                // On/Off Switch
    CircuitPlayground.redLED(HIGH);                       // On Indicator
    X = CircuitPlayground.motionX();
    Y = CircuitPlayground.motionY();

    Serial.print("X: ");                                  //Accelerometer Readings for Testing
    Serial.print(X);
    Serial.print("  Y: ");
    Serial.println(Y);

    if ((abs(X) < 1.0) && (abs(Y) < 1.0)) {                //Checks if board has stopped moving and is flat
      noMotionStreak++;                                    //Adds a successful check if board has stopped moving
      if (noMotionStreak >=20){                            //Checks no motion streak, after 20 successful checks board plays "finished" tone every 10sec until turned off
        noMotionStreak = 0;
        while(! digitalRead(A1)) {
          CircuitPlayground.playTone(1000, 3000);
          delay(10000);
        }
      }
      
    }
    else {
      noMotionStreak = 0;                                   //Resets no motion streak if motion is detected before success
    }
  }
  else {
    CircuitPlayground.redLED(LOW);
  }

  delay(100);
}

Credits

TriOmega
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.