Bed Wetter



As the school year goes on and I have to keep getting up early, I find myself accidentally falling asleep after turning off my alarm more and more. To solve this, I created a device that will dump water on me if I'm not out of bed 5 minutes after my alarm goes off.
Supplies



Required:
- Any Arduino microcontroller (I used a Particle Argon)
- A servo
- A motion sensor
- x Jumper wires
- Some material to build the structure (cardboard, wood, etc.)
- Water bottle (that you will cut a hole into)
- Button
- 220 ohm resistor (or similar)
Set Up the Microcontroller

Attach the 3.3V pin to the positive rail, and the ground pin to the ground rail
Set Up the Button

Attach the button to the D6 pin and ground
Set Up the Servo

Attach the ground to the ground rail, the positive to the 5V a.k.a VUSB pin, and the input to A5
Set Up the Motion Sensor

Attach the positive to the 3.3V positive rail, ground to the ground rail, and input to D5
Configure and Flash the Code
Flash the following code to your Argon and adjust the config variables accordingly:
int servoPin = A5;
int motionSensor = D5;
int button = D6;
// Config variables. only touch these!!! don't touch anything else
// -------------------------------------------------------------
// UTC time zone
int alarmHour = 17;
int alarmMinute = 45;
// in seconds
int delayBeforeSpray = 10;
// ------------------------------------------------------------
bool servoStarted = false;
bool disarmed = false;
int servoMin = 10;
int servoMax = 170;
Servo servo;
int alarmUnixTimestamp = 0;
int disarmTime = 0;
void setup() {
recalculateAlarm();
Serial.begin(9600);
servo.attach(servoPin);
pinMode(button, INPUT_PULLUP);
pinMode(motionSensor, INPUT);
Serial.println(alarmUnixTimestamp);
}
void recalculateAlarm() {
alarmUnixTimestamp = Time.now() + ((alarmHour - Time.hour()) * 60 * 60) + ((alarmMinute - Time.minute()) * 60) - Time.second();
Serial.println("Alarm set to " + Time.format(alarmUnixTimestamp, TIME_FORMAT_DEFAULT));
}
void disarm() {
disarmed = true;
disarmTime = Time.now();
}
void rearm() {
disarmed = false;
}
void open() {
servo.write(servoMax);
}
void close() {
servo.write(servoMin);
}
void loop() {
if (Time.now() >= alarmUnixTimestamp + delayBeforeSpray && !disarmed) {
servoStarted = true;
Serial.println("sprayed");
}
int buttonStatus = digitalRead(button);
if (buttonStatus == LOW && servoStarted && !disarmed) {
disarm();
servoStarted = false;
Serial.println("disarmed (button)");
}
int motionStatus = digitalRead(motionSensor);
if (motionStatus == HIGH && !servoStarted && !disarmed) {
disarm();
Serial.println("disarmed (motion sensor)");
}
if (Time.now() >= disarmTime + 30 && disarmed) {
rearm();
alarmMinute += 1;
recalculateAlarm();
Serial.println("rearmed");
}
}
Attach a Cap to the Servo

Cut out a surface the size of a water bottle cap and attach it to the servo. The surface can be a material of your choice
Attach to a Bottle

Attach your motor and a bottle without a cap to a tall surface so that the surface you cut earlier acts as a cap
Build the Ramp

Attach a ramp that the water will fall onto
Finish the Structure
Add walls to help support the structure. Make sure to cut holes in so that the microcontroller can get power and the motion sensor can see.