close-circle
Close

Foamy Codey

A project log for Arduino Splash Resistant Toilet Foamer

Soothing Silent Scentless Relief

VijeMiller 04/18/2017 at 03:480 Comments
// Toilet Foamer
// VijeMiller
// TVMiller.com

// Neopixel
#include <Adafruit_NeoPixel.h>
#define PINSTRIP 10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, PINSTRIP, NEO_GRB + NEO_KHZ800);

// Aerator
int aerator = 7;
// Valve
int valve = 8;

void setup() {

  Serial.begin(9600);

  // Pin Values
  pinMode(aerator, OUTPUT);
  pinMode(valve, OUTPUT);

  // Load Neopixel
  strip.begin();
  strip.show();

  digitalWrite(aerator, LOW);
  digitalWrite(valve, LOW);

}

void loop() {

  // Listen
  if (Serial.available() > 0)
  {
    digitalWrite(aerator, HIGH);
    // Prime Soap Container
    delay(3000);
    digitalWrite(valve, HIGH);
    // FOR to Delay w/ LED
    for (int i = 0; i < 15; i++) {
      colorWipe(strip.Color(255, 0, 0), 70);
      colorWipe(strip.Color(0, 255, 0), 70);
      colorWipe(strip.Color(0, 0, 255), 70);
    }
    digitalWrite(valve, LOW);
    // FOR to Delay w/ LED
    for (int i = 0; i < 500; i++) {
      colorWipe(strip.Color(255, 0, 0), 70);
      colorWipe(strip.Color(0, 255, 0), 70);
      colorWipe(strip.Color(0, 0, 255), 70);
    }
    digitalWrite(aerator, LOW);
  }
}

void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

Discussions