files.catbox.moe/jnhue9.mp4
Arduino MKR1000
(3) MG995 Servos
16X2 LCD Display
(2) Temperature Sensors
Tin Foil

- // Arduino IoT Shower
- // vgmlr
- // A1 Temp Head
- // 0 Cap 10M
- // 1 Cap 1K
- // 2 3 4 5 11 12 LCD
- // 6 LED
- // 7 Hot
- // 8 Valve
- // 9 Cold
- // Libraries
- #include "SPI.h"
- #include "WiFi101.h"
- #include "LiquidCrystal.h"
- #include "Servo.h"
- #include "CapacitiveSensor.h"
- // WiFi
- char ssid[] = "NETWORK";
- char pass[] = "PASSWORD";
- int keyIndex = 0;
- int status = WL_IDLE_STATUS;
- WiFiServer server(80);
- // ThingSpeak
- char thingSpeakAddress[] = "api.thingspeak.com";
- String APIKey = "XXXXXXXX"; // API
- const int updateThingSpeakInterval = 10 * 1000; // Interval
- long lastConnectionTime = 0;
- boolean lastConnected = false;
- WiFiClient client;
- // LCD
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- // Servos
- Servo hot;
- Servo valve;
- Servo cold;
- int openturn = 0;
- int closeturn = 180;
- int noturn = 90;
- // Servo Position Delays
- int hotdelay = 450;
- int valvedelay = 700;
- int colddelay = 300;
- // Temperature
- int temptub = A0;
- int temphead = A1;
- int templow = 0;
- int temphigh = 0;
- int tempc = 0;
- int pretempf = 0;
- // Temperature Variable
- int settemp = 42;
- int preptemp = 0;
- int tempvarlow = 0;
- int tempvarhigh = 0;
- // Map Variables
- int lowvol = 400;
- int highvol = 1005;
- int lowc = 56;
- int highc = 131;
- // On Off Button
- CapacitiveSensor onoffbutton = CapacitiveSensor(0, 1);
- int touchpeak = 150;
- // State
- // 0 = Off
- // 1 = Turn On
- // 2 = On
- // 3 = Shut Off
- int state = 0;
- void setup() {
- Serial.begin(9600);
- // Servos
- hot.attach(7);
- valve.attach(8);
- cold.attach(9);
- hot.write(90);
- valve.write(90);
- cold.write(90);
- // Temperature
- pinMode(temptub, INPUT);
- pinMode(temphead, INPUT);
- // LCD
- lcd.begin(16, 2);
- lcd.clear();
- // WIFI Connection
- while ( status != WL_CONNECTED) {
- lcd.setCursor(0, 0);
- lcd.print("Connecting...");
- lcd.setCursor(0, 1);
- lcd.print(ssid);
- Serial.print("Connecting Network: ");
- Serial.println(ssid);
- status = WiFi.begin(ssid, pass);
- delay(10000);
- }
- server.begin();
- lcd.clear();
- printWifiStatus();
- delay(3000);
- lcd.clear();
- }
- void loop() {
- // WiFi Server Page
- if (state == 0) {
- WiFiClient client = server.available();
- if (client) {
- String currentLine = "";
- while (client.connected()) {
- if (client.available()) {
- char c = client.read();
- Serial.write(c);
- if (c == '\n') {
- if (currentLine.length() == 0) {
- client.println("HTTP/1.1 200 OK");
- client.println("Content-type:text/html");
- client.println();
- client.print("");
- client.print("