TVShow S01E23 HackADay Maker Crown
Nine servos parade the acrylic molded crown, affixed in an arrayed scheme plotted by the Arduino MKR1000. A seated position is the first form, a calm but present light shone. When your Grace rises and depresses a button on his Pebble Classic, a second nobler form takes shape and a tweet is consigned notifying the peasants and Lords to bow their heads in reverence. Conflict arises, the crown must amend to suit an embattled King, the third form protective and fierce; another tweet is dispatched, protect your King!



Built entirely from refuse aside from the donated MKR1000

Notation
Much stood against I in this attempted episode that the artifactual quality is as consequence of surrender I shall avoid admitting to directly. My kingdom for a green screen and light box...and 3D printer and CNC and...

Written, Directed and Lobbed Scimitar by TVMiller
Filmed by a Bloody Peasant holding a Droid Razr

Arduino Nude Sketch

// Maker Crown @TVMiller

#include <Servo.h>
#include <SPI.h>
#include <WiFi101.h>

// Servos
Servo serone;
Servo sertwo;
Servo serthree;
Servo serfour;
Servo serfive;
Servo sersix;
Servo serseven;
Servo sereight;
Servo sernine;

// Seat Positions
int seatposone = 180; // Long
int seatposoneA = 150;
int seatpostwo = 10; // Short
int seatpostwoA = 70;
int seatposthree = 130; // Long
int seatposthreeA = 85;
int seatposfour = 0; // Short
int seatposfourA = 45;
int seatposfive = 1; // Long
int seatposfiveA = 40;
int seatpossix = 170; // Long
int seatpossixA = 130;
int seatposseven = 7; // Short
int seatpossevenA = 35;
int seatposeight = 170; // Long
int seatposeightA = 125;
int seatposnine = 7; // Short
int seatposnineA = 45;

// Seat Place Holders
int posone = seatposone;
int postwo = seatpostwo;
int posthree = seatposthree;
int posfour = seatposfour;
int posfive = seatposfive;
int possix = seatpossix;
int posseven = seatposseven;
int poseight = seatposeight;
int posnine = seatposnine;

// Delays
int sitdelay = 20;
int risedelay = 15;
int battledelay = 5;

// LED
int red = 11;
int green = 12;
int blue = 10;

// State
int state = 0;

// 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 = "APIKEY"; // API
const int updateThingSpeakInterval = 100 * 1000; // Interval
long lastConnectionTime = 0;
boolean lastConnected = false;
WiFiClient client;

void setup() {

Serial.begin(9600);

// Servos Short
sertwo.attach(2);
serfour.attach(4);
serseven.attach(7);
sernine.attach(9);

// Servos Long
serone.attach(1);
serthree.attach(3);
serfive.attach(5);
sersix.attach(6);
sereight.attach(8);

// Lights
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);

serone.write(seatposone);
sertwo.write(seatpostwoA);
serthree.write(seatposthree);
serfour.write(seatposfourA);
serfive.write(seatposfive);
sersix.write(seatpossix);
serseven.write(seatpossevenA);
sereight.write(seatposeight);
sernine.write(seatposnineA);

digitalWrite(red, HIGH);
delay(500);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(500);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
delay(500);
digitalWrite(blue, LOW);

// WIFI Connection
while ( status != WL_CONNECTED) {
Serial.print("Connecting Network: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(5000);
}
server.begin();
printWifiStatus();
}

void loop() {

// Pebble WIFI Coms
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");
break;
}
else {
currentLine = "";
}
}
else if (c != '\r') {
currentLine += c;
}

if (currentLine.endsWith("GET /R")) {
state = 1;
}
if (currentLine.endsWith("GET /B")) {
state = 3;
}
if (currentLine.endsWith("GET /S")) {
state = 0;
}
}
}
client.stop();
}

// Serial Input (Testing)
if (Serial.available()) {
char ser = Serial.read();
switch (ser) {
case '0':
state = 0;
break;
case '1':
state = 1;
break;
case '2':
state = 3;
break;
}
}

// State Change
if (state == 1) {
rise();
String kingpos = String(state, DEC);
updateThingSpeak("field1=" + kingpos);
}
else if (state == 2) {

}
else if (state == 3) {
battle();
String kingpos = String(state, DEC);
updateThingSpeak("field1=" + kingpos);
}
else if (state == 4) {

}
else {
seated();
String kingpos = String(state, DEC);
if (millis() - lastConnectionTime > updateThingSpeakInterval) {
updateThingSpeak("field1=" + kingpos);
}
}

}

void printWifiStatus() {
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
Serial.print("http://");
Serial.println(ip);
long rssi = WiFi.RSSI();
Serial.print("RSSI: ");
Serial.print(rssi);
Serial.println(" dBm");
}

void updateThingSpeak(String tsData) {
if (client.connect(thingSpeakAddress, 80)) {
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + APIKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
lastConnectionTime = millis();
}
}

void seated() {

digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);

serone.write(seatposone);
serthree.write(seatposthree);
serfive.write(seatposfive);
sersix.write(seatpossix);
sereight.write(seatposeight);

for (postwo = seatpostwoA; postwo >= seatpostwo; postwo -= 1) {
sertwo.write(postwo);
delay(sitdelay);
}
for (posfour = seatposfourA; posfour >= seatposfour; posfour -= 1) {
serfour.write(posfour);
delay(sitdelay);
}
delay(500);
for (posseven = seatpossevenA; posseven >= seatposseven; posseven -= 1) {
serseven.write(posseven);
delay(sitdelay);
}
for (posnine = seatposnineA; posnine >= seatposnine; posnine -= 1) {
sernine.write(posnine);
delay(sitdelay);
}

for (postwo = seatpostwo; postwo <= seatpostwoA; postwo += 1) {
sertwo.write(postwo);
delay(sitdelay);
}
for (posfour = seatposfour; posfour <= seatposfourA; posfour += 1) {
serfour.write(posfour);
delay(sitdelay);
}
delay(500);
for (posseven = seatposseven; posseven <= seatpossevenA; posseven += 1) {
serseven.write(posseven);
delay(sitdelay);
}
for (posnine = seatposnine; posnine <= seatposnineA; posnine += 1) {
sernine.write(posnine);
delay(sitdelay);
}
}

void rise() {

digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);

sertwo.write(seatpostwoA);
serfour.write(seatposfourA);
serseven.write(seatpossevenA);
sernine.write(seatposnineA);

for (posone = seatposone; posone >= seatposoneA; posone -= 1) {
serone.write(posone);
delay(risedelay);
}
for (posthree = seatposthree; posthree >= seatposthreeA; posthree -= 1) {
serthree.write(posthree);
delay(risedelay);
}
for (posfive = seatposfive; posfive <= seatposfiveA; posfive += 1) {
serfive.write(posfive);
delay(risedelay);
}
for (possix = seatpossix; possix >= seatpossixA; possix -= 1) {
sersix.write(possix);
delay(risedelay);
}
for (poseight = seatposeight; poseight >= seatposeightA; poseight -= 1) {
sereight.write(poseight);
delay(risedelay);
}
state = 2;
}

void battle() {

digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);

for (posone = seatposoneA; posone <= seatposone; posone += 1) {
serone.write(posone);
delay(battledelay);
}
for (postwo = seatpostwoA; postwo >= seatpostwo; postwo -= 1) {
sertwo.write(postwo);
delay(battledelay);
}
for (posthree = seatposthreeA; posthree <= seatposthree; posthree += 1) {
serthree.write(posthree);
delay(battledelay);
}
for (posfour = seatposfourA; posfour >= seatposfour; posfour -= 1) {
serfour.write(posfour);
delay(battledelay);
}
for (posfive = seatposfiveA; posfive >= seatposfive; posfive -= 1) {
serfive.write(posfive);
delay(battledelay);
}
for (possix = seatpossixA; possix <= seatpossix; possix += 1) {
sersix.write(possix);
delay(battledelay);
}
for (posseven = seatpossevenA; posseven >= seatposseven; posseven -= 1) {
serseven.write(posseven);
delay(battledelay);
}
for (poseight = seatposeightA; poseight <= seatposeight; poseight += 1) {
sereight.write(poseight);
delay(battledelay);
}
for (posnine = seatposnineA; posnine >= seatposnine; posnine -= 1) {
sernine.write(posnine);
delay(battledelay);
}
state = 4;
}

Pebble JS App

// Maker Crown Peddle APP (Version 1.0) @TVMiller 

var UI = require('ui');
var ajax = require('ajax');
var Vector2 = require('vector2');

// Create Window
var main_window = new UI.Window();

// Open Button and Display
var txtOnLabel = new UI.Text({
position: new Vector2(0, 15),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'RISE',
textAlign: 'center',
color: 'white'
});

//this is going to be our off button
var txtOffLabel = new UI.Text({
position: new Vector2(0, 95),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'BATTLE',
textAlign: 'center',
color: 'white'
});

main_window.backgroundColor('black');
main_window.add(txtOnLabel);
main_window.add(txtOffLabel);
main_window.show();

// URL To MKR1000 (Change)
function Toggle(function_name){
var URL = 'http://192.168.1.9/' + function_name;

ajax(
{
url: URL,
method: 'post',
type: 'json',
data: { "args": function_name}
}
);
}

// Rise
main_window.on('click', 'up', function() {
Toggle('R');
});
// Battle
main_window.on('click', 'down', function() {
Toggle('B');
});
// Seated
main_window.on('click', 'select', function() {
Toggle('S');
});

Archive
HackADay.io - Maker Crown
ThingSpeak - ThingTweet Tutorial
@AtmelMakes - Tweet
TVShow S01E22 Idle Waste Alarm



A growing contradiction of the masses is concern for the environment while simultaneously being wasteful slobs. The belief that self matters veiled by an internet fog often perverts attention to atmospheric abuse and trivial consumption of resources that a human just 40 years ago would have milked for every drop.

One very aggravating all too frequent observation is the running-automobile-phone-user. A text or status update in your running parked car I would equate to treason. In reality, sheep and shepherd are the only true biological conditions of our species; so here is a first version shock blanket for your filthy habit.

Ideally, such a device may be wired and concealed, programmed by manufacturer (eh?!) or self prescribed to treat such a disability. In this particular model, an accelerometer affixed to an Arduino Nano reads variations of movement, accumulating time idling to a warning after 2 minutes, as to navigate around average traffic light pauses.

A pending model utilizing the Arduino MKR1000 stores the motion to idle ratio and warnings, then when near a known network, transmits the stored data to ThingSpeak for collection and analysis.

Stop being who you are now because is it not better in spite of your comforts.

Research

Idle Fuel Consumption
0.6L/HR per Liter Engine Displacement

Sample
Toyota Camry 2.5L 4CYL (#1 U.S. Mid-sized Sedan)
2.5 x 0.6 = 1.5 ÷ 60 = 0.025L/M

Idle Pollution
9 gram(s) of toxins (ex. CO2) per 1 minute

Walmart Locations
United States 4,540
International 6,301
Sam's Club 647

Calculation (Muted Prognosis)
10 Idle Texters per Day per U.S. Walmart Parking Lot
10 x 4,540 = 45,400

45,400 x 9 = 408,600 Grams (901 Pounds) of Pollutants per Minute
408,600 x 5 Minutes Texting = 2,043,000 Grams (4,504 Pounds)
408,600 x 20 Minutes = 8,172,000 Grams (18,016 Pounds)

45,400 x 0.025 = 1,135 Liters (299.8 Gallons) per Minute
1,135 x 5 Minutes Texting = 5,675 Liters (1,499 Gallons)
1,135 x 20 Minutes = 22,700 Liters (5,997 Gallons)

Written, Directed and Accelerated by TVMiller
Filmed too Fast and also too Furiously through a Droid Razr

Arduino Sketch
// Idle Waste Alarm
// Pre MKR1000 Version
// Version 1.0 @TVMiller
// MPU-6050 Sketch JohnChi

#include<Wire.h>

// I2C address of the MPU-6050
const int MPU_addr = 0x68;
int16_t AcY;

// Sensitivity
int high = 2700;
int low = -2700;
int set = 0;
int dif = 0;
// State
int state = 1;
// Time Variables
long echo = 0;
int dly = 100;
// 120 seconds
// Avg red light Wait 90 seconds
long sepone = 22500;
long septwo = 45000;
long septhree = 67500;
long sepfour = 90000;

// LEDs and Piezo
// Green
int one = 3;
int two = 4;
int three = 5;
// Yellow
int four = 6;
// Red and Piezo
int five = 7;

void setup() {

Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);

Serial.begin(9600);

pinMode(one, OUTPUT);
pinMode(two, OUTPUT);
pinMode(three, OUTPUT);
pinMode(four, OUTPUT);
pinMode(five, OUTPUT);

digitalWrite(one, HIGH);
digitalWrite(two, LOW);
digitalWrite(three, LOW);
digitalWrite(four, LOW);
digitalWrite(five, LOW);

}

void loop() {

// GY-52 Communication
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr, 14, true);

// 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcY = Wire.read() << 8 | Wire.read();

// Variance From Last Position
dif = AcY - set;

// Testing
Serial.print("YAxi ");
Serial.print(AcY);
Serial.print(" Difr ");
Serial.print(dif);
Serial.print(" Mils ");
Serial.println(echo);

// IF Motion Reset Minimums
if (dif > high || dif < low) {
digitalWrite(one, HIGH);
digitalWrite(two, LOW);
digitalWrite(three, LOW);
digitalWrite(four, LOW);
digitalWrite(five, LOW);
state = 1;
echo = 0;
}
else {
if (state == 1) {
if (echo >= sepone) {
digitalWrite(two, HIGH);
state = 2;
}
}
else if (state == 2) {
if (echo >= septwo) {
digitalWrite(three, HIGH);
state = 3;
}
}
else if (state == 3) {
if (echo >= septhree) {
digitalWrite(four, HIGH);
state = 4;
}
}
else if (state == 4) {
if (echo >= sepfour) {
digitalWrite(five, HIGH);
}
}
}

// Reset Last Position
set = AcY;

// 1/10 Second
echo = echo + dly;
delay(dly);
}

Archive
HackADay - Car Idle Alarm Helps You Stop Wasting Gas While Tweeting
HackADay.io - Idle Waste Alarm
TVShow S01E20 Arduino IoT Shower (w/ Arduino MKR1000)



Annotation; this was/is a first prototype.

Collaborating water and electricity seems as almost common sense as pairing a young Petit Chablis with a spaghetti alla vongole. As an alternative to the several thousand dollar pre-installed branded electronically controlled shower, a few attempts at creating a DIY automated shower have appeared over the years, though, applied with immense exchange of existing components and not best utilizing the newer era of IoT. Here, we have sympathetically married abundantly common pre-existing shower valves with the yet to be released Arduino MKR1000 to create an automated, connected and subsequently more efficient bathing experience.

Through either the Windows 10 or Android application, you may preset an optimal temperature and begin the shower. The MKR1000 will then monitor and regulate the temperature and shower valve to create a luxurious escapade in your dirt ass poor bath room. The amount of time and temperature variation will be sent in real time to ThingSpeak where it can be monitored for display and personal analysis of water consumption.

Additional notation; the popsicle sticks were a late second amendment to gain leverage.

Written, Directed and Moistened by TVMiller
Filmed, Rinsed and Repeated on a Droid Razr

Arduino Sketch
// Arduino IoT Shower V1.0 @TVMiller
// Hackster.io Arduino MKR1000 Beta

// A0 Temp Tub
// 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("<body bgcolor=\"#9999FF\">");
client.print("<div align=\"center\">");
client.print("<table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" style=\" border:1px solid #000000;background-color:#FFFFFF;\">
<tr><td style=\"padding:5px;font:50px tahoma;\">");
client.print(settemp);
client.print("</td></tr></table>");
client.print("<a href=\"/U\"><img src=\"
http://yoursite.com/images/uparrow.png\" border=\"0\"></a>
<a href=\"/D\"><img src=\"http://yoursite.com/images/
downarrow.png\" border=\"0\"></a><br />");
client.print("<br />");
client.print("<a href=\"/S\"><img src=\"http://yoursite.
com/images/showeron.png\" border=\"0\"></a>");
client.print("</div>");
client.println();
break;
}
else {
currentLine = "";
}
}
else if (c != '\r') {
currentLine += c;
}

if (currentLine.endsWith("GET /U")) {
settemp = settemp + 1;
}
if (currentLine.endsWith("GET /D")) {
settemp = settemp - 1;
}
if (currentLine.endsWith("GET /S")) {
state = 1;
}
}
}
client.stop();
}
}

// On Off Button
long touch = onoffbutton.capacitiveSensor(30);
if (touch > touchpeak) {
if (state == 0) {
state = 1;
}
else if (state == 2) {
state = 3;
}
}

// Update ThingSpeak
if (state == 1 || state == 2) {
temphigh = analogRead(temphead);
pretempf = map(temphigh, lowvol, highvol, lowc, highc);
tempc = (pretempf - 32) * 5 / 9;
String headtemperature = String(tempc, DEC);
String runtime = String(state, DEC);
if (millis() - lastConnectionTime > updateThingSpeakInterval) {
updateThingSpeak("field1=" + runtime + "&field2=" + headtemperature);
}
}

// State Operation
if (state == 1) {
turnon();
}
else if (state == 2) {
shower();
}
else if (state == 3) {
turnoff();
}

}

void printWifiStatus() {
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
Serial.print("http://");
Serial.println(ip);
long rssi = WiFi.RSSI();
Serial.print("RSSI: ");
Serial.print(rssi);
Serial.println(" dBm");
lcd.setCursor(0, 0);
lcd.print(WiFi.SSID());
lcd.setCursor(0, 1);
lcd.print(ip);
}

void updateThingSpeak(String tsData) {
if (client.connect(thingSpeakAddress, 80)) {
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + APIKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
lastConnectionTime = millis();
}
}

void turnon() {

// LCD Temperature Display
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Set Temp:");
lcd.setCursor(10, 0);
lcd.print(settemp);
lcd.setCursor(0, 1);
lcd.print("Current:");
lcd.setCursor(9, 1);
lcd.print("0");

// Hot Open Valve Tub Cold Closed
hot.write(180);
delay(hotdelay);
hot.write(90);

delay(2000);

preptemp = settemp - 2;

// Wait For Temp
while (preptemp > tempc) {
templow = analogRead(temptub);
pretempf = map(templow, lowvol, highvol, lowc, highc);
tempc = (pretempf - 32) * 5 / 9;
lcd.setCursor(9, 1);
lcd.print(tempc);
String headtemperature = String(tempc, DEC);
if (millis() - lastConnectionTime > updateThingSpeakInterval) {
updateThingSpeak("&field2=" + headtemperature);
}
}

// Hot Open Valve Tub Cold Open
cold.write(180);
delay(colddelay);
cold.write(90);

// Delay For While Statement
delay(2000);

// Wait For Temp
while (preptemp > tempc) {
templow = analogRead(temptub);
pretempf = map(templow, lowvol, highvol, lowc, highc);
tempc = (pretempf - 32) * 5 / 9;
lcd.setCursor(9, 1);
lcd.print(tempc);
String headtemperature = String(tempc, DEC);
if (millis() - lastConnectionTime > updateThingSpeakInterval) {
updateThingSpeak("&field2=" + headtemperature);
}
}

// Hot Open Valve Head Cold Open
valve.write(180);
delay(valvedelay);
valve.write(90);

// Set State On
state = 2;

// Update State ThingSpeak
String runtime = String(state, DEC);
updateThingSpeak("field1=" + runtime);

}

void shower() {

// Get Temp Shower Head
temphigh = analogRead(temphead);
pretempf = map(temphigh, lowvol, highvol, lowc, highc);
tempc = (pretempf - 32) * 5 / 9;

// Print Shower Temp
lcd.setCursor(9, 1);
lcd.print(tempc);

// Set Temperature Leeway
tempvarlow = settemp - 2;
tempvarhigh = settemp + 2;

// Adjust Temperature
if (tempc < tempvarlow) {
cold.write(0);
delay(100);
cold.write(90);
colddelay = colddelay - 100;
delay(2000);
}
else if (tempc > tempvarhigh) {
cold.write(180);
delay(100);
cold.write(90);
colddelay = colddelay + 100;
delay(2000);
}

}

void turnoff() {

// Get Temp Shower Head
temphigh = analogRead(temphead);
pretempf = map(temphigh, lowvol, highvol, lowc, highc);
tempc = (pretempf - 32) * 5 / 9;

// Print Shower Temp
lcd.setCursor(9, 1);
lcd.print(tempc);

// Close Valve
valve.write(0);
delay(valvedelay);
valve.write(90);

// Close Hot
hot.write(0);
delay(hotdelay);
hot.write(90);

// Close Cold
cold.write(0);
delay(colddelay);
cold.write(90);

// Reset All States
state = 0;
templow = 0;
temphigh = 0;
tempc = 0;
colddelay = 400;

delay(1000);

// Update ThingSpeak FINAL
String headtemperature = String(tempc, DEC);
String runtime = String(state, DEC);
updateThingSpeak("field1=" + runtime + "&field2=" + headtemperature);

delay(5000);

// Clear LCD
lcd.clear();
}

Archive
HackADay - Start your day the Arduino way with this IoT shower controller
Hackster.io - Arduino IoT Shower
HackADay.io - Arduino IoT Shower
Adafruit - Automate Your Shower with Arduino and IoT
Atmel - Connect and Automate Your 'Dumb' Shower with Arduino MKR1000
TVShow S01E19 Gate Jedi



Having discovered several spare Midichlorians in my liquor cabinet, I trained and applied them to opening a large cumbersome gate. The FORCE motion travels through my inner what-nots and is translated by the Pebble Classic accelerometer toggling a command sent to the (Particle) Cloud (City) which returns to the Particle Photon triggering a TIP120 to fire a button on an existing RF transceiver.

May the ridiculous hand gestures be with you, always.

Written, Directed and Hate Flowed Through by TVMiller
Filmed through 12 parsecs and not the Droid Razr you were looking for

Particle Photon Code
// Gate Jedi @TVMiller

int sig = D7;
int command = 0;

void setup() {
pinMode(sig, OUTPUT);
Spark.function("gate",gateJedi);
digitalWrite(sig, LOW);
}

void loop() {
}

int gateJedi(String command) {
if (command=="open") {
digitalWrite(sig,HIGH);
delay(3000);
digitalWrite(sig,LOW);
command = 0;
}
else {
digitalWrite(sig,LOW);
}
}

Pebble.js Gate Jedi APP
// Gate Jedi Peddle APP (Version 1.3) @TVMiller 
// Pebble Blink APP @Jack-Dangerfield

var Accel = require('ui/accel');
Accel.init();
var UI = require('ui');
var ajax = require('ajax');
var Vector2 = require('vector2');

// Create Window
var main_window = new UI.Window();

// Open Button and Display
var txtOnLabel = new UI.Text({
position: new Vector2(0, 50),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'GATE JEDI',
textAlign: 'center',
color: 'white'
});

// Display Main Window
main_window.backgroundColor('black');
main_window.add(txtOnLabel);
main_window.show();

// URL To Particle Cloud
function Toggle(function_name,function_value){
var URL = 'https://api.particle.io/v1/devices/DEVICE
ID/' + function_name +'?access_token=TOKEN';

ajax(
{
url: URL,
method: 'post',
type: 'json',
data: { "args": function_value}
}
);
}

// Accelerometer Poll and Function (Default 100Hz 25)
Accel.on('data', function(e) {
console.log(e.accel.x);
if (e.accel.x > 900) {
console.log(e.accel.y);
if (e.accel.y > 900) {
Toggle('gate','open');
}}
});

// Button Function and Photon Parameters
main_window.on('click', 'up', function() {
Toggle('gate','open');
});

Archive
HackADay - Open Sesame, from a Galaxy Far, Far Away
Hackster.io - Gate Jedi
HackADay.io - Gate Jedi
Resistance Theory (2D Rendering) Distance
Field state regulates in a static three dimensional position of a distance of one oscillation. Irregularity of collusion point from any direction alters position of opposition, intensity and subsequently state.


Arduino Wave Generator Tank (Speed Adjustable Only)



// Arduino Wave Tank II
// TVMiller

#include <Servo.h>

Servo left;
Servo right;

int pos = 20;
int back = 20;
int forward = 160;
int spe = 15;

int red = 6;
int green = 5;
int blue = 4;

void setup() {

Serial.begin(9600);

left.attach(2);
right.attach(3);

pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);

left.write(back);
right.write(back);

digitalWrite(green, HIGH);
delay(1000);
digitalWrite(green, LOW);
delay(1000);
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(red, LOW);
delay(1000);

}

void loop() {

int pent = analogRead(A0);
Serial.println(pent);
spe = map(pent, 0, 1023, 15, 1);

if (spe >= 10) {
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
}
else if (spe < 10 && spe >= 5) {
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
}
else if (spe < 5 && spe >= 1) {
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
}

for (pos = back; pos <= forward; pos += 1) {
left.write(pos);
right.write(pos);
delay(spe);
}
for (pos = forward; pos >= back; pos -= 1) {
left.write(pos);
right.write(pos);
delay(spe);
}
}

Archive
TVMiller - TVShow S01E16 Arduino Wave Generator Tank
TVShow S01E16 Arduino Wave Generator Tank




Welcome me matey to Davy Jones' miniature locker. To analyze yer wave and buoyancy mechanics while we plunder wenches, drink Rum and supplement with vitamin C, we rigged an Arduino Micro, (2) servos and potentiometer with if and for codes to generate various wave frequencies upon the sovereign seas (in a small acrylic case cast from a picture frame). Arrr--gh!

Written, Directed and Heave Ho'd by TVMiller
Filmed through 20,000 Leagues and Droid Razr

// Arduino Wave Tank
// TVMiller

#include <Servo.h>

Servo left;
Servo right;

int pos = 20;
int post = 160;
int back = 20;
int forward = 160;

int red = 6;
int green = 5;
int blue = 4;

int slow = 8;
int fast = 4;

void setup() {

Serial.begin(9600);

left.attach(2);
right.attach(3);

pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);

left.write(back);
right.write(back);

digitalWrite(green, HIGH);
delay(1000);
digitalWrite(green, LOW);
delay(1000);
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(red, LOW);
delay(1000);

}

void loop() {

int pent = analogRead(A0);
Serial.println(pent);

if (pent < 200) {
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
digitalWrite(green, LOW);
for (pos = back; pos <= forward; pos += 1) {
left.write(pos);
right.write(pos);
delay(slow);
}
for (pos = forward; pos >= back; pos -= 1) {
left.write(pos);
right.write(pos);
delay(slow);
}
}
else if (pent > 200 && pent < 450) {
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
for (pos = back; pos <= forward; pos += 1) {
left.write(pos);
right.write(pos);
delay(fast);
}
for (pos = forward; pos >= back; pos -= 1) {
left.write(pos);
right.write(pos);
delay(fast);
}
}
else if (pent > 450 && pent < 700) {
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
for (pos = back; pos <= forward; pos += 1) {
post = map(pos, 20, 160, 160, 20);
left.write(pos);
right.write(post);
delay(slow);
}
for (pos = forward; pos >= back; pos -= 1) {
post = map(pos, 160, 20, 20, 160);
left.write(pos);
right.write(post);
delay(slow);
}
}
else if (pent > 700 && pent < 1023) {
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
for (pos = back; pos <= forward; pos += 1) {
post = map(pos, 20, 160, 160, 20);
left.write(pos);
right.write(post);
delay(fast);
}
for (pos = forward; pos >= back; pos -= 1) {
post = map(pos, 160, 20, 20, 160);
left.write(pos);
right.write(post);
delay(fast);
}
}

}

Archive
HackADay.io - Arduino Wave Generator Tank
Hackster.io - Arduino Wave Generator Tank
TVMiller - Arduino Wave Generator Tank (Speed Adjustable Only)
TVShow S01E14 Mobile Coeur d'Alene Floating 14th Hole




The elite Coeur d'Alene Resort is an exquisite luxurious encounter nestled on a lake in Idaho. I live in a shack; thus the odds of entertaining such a blessed experience are currently, null. In an attempt to bring this hedonistic wealth home, we have reproduced (maked) golf's now infamous floating 14th.

The scaled golf green sits upon an Arduino Uno and Seeed Studio Relay controlled motor array affixed by a bluetooth that interacts with an Android phone application created in MIT App Inventor to much like the parent object, adjust distance relative to user. Steering is automated to control center by an Arduino Micro and 2 ultrasonic sensors spitting out distance to elevated impediments. It's a glorified chipping mat folks!

It should be noted that TVMiller won the HackADay Golf Tournament by 4 strokes. That's what she said.

Written, Directed and Sub Parred by TVMiller
Guest Starring TVMiller
Filmed with a Fade and Droid Razr

Arduino MCDL14 Drive Sketch

// MCDL14 Drive
// TVMiller

#include <SoftwareSerial.h>

// 6.25 Inch Rotation
// 5.76 Rotations Per Yard
// 1.25 Seconds Per Rotation
// 7.2 Seconds Per Yard

SoftwareSerial btsend(11, 10);

const int alive = 13;

//Forward
const int posfwd = 4;
const int negfwd = 6;

//Backward
const int posbak = 5;
const int negbak = 7;

// Last Position
int pos = 0;
int rot = 0;
char btrec;

// Run Time (Ref.)
int zero = 0;
int forty = 5555;
int fifty = 6944;
int sixty = 8333;
int seventy = 9722;
int eigthy = 11111;
int ninety = 12500;

void setup() {
Serial.begin(9600);
btsend.begin(9600);

pinMode(alive, OUTPUT);
pinMode(posfwd, OUTPUT);
pinMode(negfwd, OUTPUT);
pinMode(posbak, OUTPUT);
pinMode(negbak, OUTPUT);
}

void loop() {

// Bluetooth Coms
while (btsend.available()) {
btrec = btsend.read();

Serial.println(btrec);
Serial.println(pos);

// 40 Yards
if (btrec == '1') {
if (pos > forty) {
rot = pos - forty;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = forty;
}
else if (pos < forty) {
rot = forty - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = forty;
}
else if (pos == forty) {
halt();
pos = forty;
}
}

// 50 Yards
if (btrec == '2') {
if (pos > fifty) {
rot = pos - fifty;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = fifty;
}
else if (pos < fifty) {
rot = fifty - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = fifty;
}
else if (pos == fifty) {
halt();
pos = fifty;
}
}

// 60 Yards
if (btrec == '3') {
if (pos > sixty) {
rot = pos - sixty;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = sixty;
}
else if (pos < sixty) {
rot = sixty - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = sixty;
}
else if (pos == sixty) {
halt();
pos = sixty;
}
}

// 70 Yards
if (btrec == '4') {
if (pos > seventy) {
rot = pos - seventy;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = seventy;
}
else if (pos < seventy) {
rot = seventy - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = seventy;
}
else if (pos == seventy) {
halt();
pos = seventy;
}
}

// 80 Yards
if (btrec == '5') {
if (pos > eigthy) {
rot = pos - eigthy;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = eigthy;
}
else if (pos < eigthy) {
rot = eigthy - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = eigthy;
}
else if (pos == eigthy) {
halt();
pos = eigthy;
}
}

// 90 Yards
if (btrec == '6') {
if (pos > ninety) {
rot = pos - ninety;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = ninety;
}
else if (pos < ninety) {
rot = ninety - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = ninety;
}
else if (pos == ninety) {
halt();
pos = ninety;
}
}

// Home
if (btrec == '7') {
if (pos > zero) {
rot = pos - zero;
Serial.println(rot);
backward();
delay(rot);
halt();
pos = zero;
}
else if (pos < zero) {
rot = zero - pos;
Serial.println(rot);
forward();
delay(rot);
halt();
pos = zero;
}
else if (pos == zero) {
halt();
pos = zero;
}
}
}
}
void backward() {
Serial.println("backward");
digitalWrite(posbak, HIGH);
digitalWrite(negbak, HIGH);
digitalWrite(alive, HIGH);
}
void forward() {
Serial.println("forward");
digitalWrite(posfwd, HIGH);
digitalWrite(negfwd, HIGH);
digitalWrite(alive, HIGH);
}
void halt() {
Serial.println("stop");
digitalWrite(posfwd, LOW);
digitalWrite(negfwd, LOW);
digitalWrite(posbak, LOW);
digitalWrite(negbak, LOW);
digitalWrite(alive, LOW);
}

Archive
HackADay - Mobile Mini Green Recreates Coeur d’Alene’s Floating 14th Hole
HackADay.io - Mobile Coeur d'Alene Floating 14th Hole
Hackster.io - Mobile Coeur d'Alene Floating 14th Hole
Seeed Studio - Mobile Coeur d'Alene Floating 14th Hole
TVMiller - Mobile Coeur d'Alene Floating 14th Hole (The End)
TVShow S01E12 Magician's Assistant (Jacob)


Practicing prestidig...prestidigiti...illusions requires one to take another in to one's confidence...or...

The assistant makes use of an optic to discretion between light and dark then store and reference the variance for a pass-fail search. The mechanical function is operated by an Arduino Uno and communicated by our resident artificial automation Jacob.

Written, Directed and Jazz Hands by TVMiller
Guest Starring Jacob
Filmed with Hypnosis and Droid Razr

Update
Seeing as it was noted in a comment, the card coincidentally at the bottom is NOT the card Jacob chose if you look closely. I am no hack...see what I did there?!

Archive
HackADay.io - Magician's Assistant
Hackster.io - Magician's Assistant
Adafruit - Make A Magician’s Assistant With Arduino
Magnetic Experiment 002