FollowTV (1)
Frequently shifting position in my laboratory viewing solution utilizing (3) ultrasonic sensors, (3) servos, an Arduino Uno and an excessive amount of averaging (see below) to lessen interference.
(Advice) Never buy HC-SR04 sensors, blech, double blech.



// FollowTV
// TVMiller

#include <Servo.h>

const int atpin = 2;
const int aepin = 3;
const int btpin = 4;
const int bepin = 5;
const int ctpin = 6;
const int cepin = 7;

// For Cycle
const int num = 15;
int i = 0;
// Limit Distance
const int limit = 5500;
int hold = 500;

long adur, atot, afix;
long bdur, btot, bfix;
long cdur, ctot, cfix;

Servo lfs; // Left Front Speaker
const int lfsout = 69;
const int lfsin = 92;

Servo mon; // Monitor
const int monl = 145;
const int monc = 91;
const int monr = 45;

Servo rfs; // Right Front Speaker
const int rfsin = 63;
const int rfsout = 78;

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

pinMode(atpin, OUTPUT);
pinMode(aepin, INPUT);
pinMode(btpin, OUTPUT);
pinMode(bepin, INPUT);
pinMode(ctpin, OUTPUT);
pinMode(cepin, INPUT);

lfs.attach(8);
mon.attach(9);
rfs.attach(10);

digitalWrite(atpin, LOW);
digitalWrite(btpin, LOW);
digitalWrite(ctpin, LOW);

lfs.write(lfsin);
mon.write(monc);
rfs.write(rfsin);

}

void loop() {

atot = 0;
for (i=0; i <= num; i++){
digitalWrite(atpin, HIGH);
delayMicroseconds(10);
digitalWrite(atpin, LOW);
adur = pulseIn(aepin, HIGH);
if (adur > limit) {
adur = limit;
}
atot = atot + adur;
}
afix = atot / num;

btot = 0;
for (i=0; i <= num; i++){
digitalWrite(btpin, HIGH);
delayMicroseconds(10);
digitalWrite(btpin, LOW);
bdur = pulseIn(bepin, HIGH);
if (bdur > limit) {
bdur = limit;
}
btot = btot + bdur;
}
bfix = btot / num;

ctot = 0;
for (i=0; i <= num; i++){
digitalWrite(ctpin, HIGH);
delayMicroseconds(10);
digitalWrite(ctpin, LOW);
cdur = pulseIn(cepin, HIGH);
if (cdur > limit) {
cdur = limit;
}
ctot = ctot + cdur;
}
cfix = ctot / num;

Serial.print(afix);
Serial.print(" ");
Serial.print(bfix);
Serial.print(" ");
Serial.println(cfix);

if (afix < bfix && afix < cfix) {
// Position 2
lfs.write(lfsout);
mon.write(monl);
rfs.write(rfsin);
}
else if (bfix < afix && bfix < cfix) {
// Position 1 and 3
lfs.write(lfsin);
mon.write(monc);
rfs.write(rfsin);
}
else if (cfix < afix && cfix < bfix) {
// Position 4
lfs.write(lfsin);
mon.write(monr);
rfs.write(rfsout);
}
else if (afix == limit && bfix == limit && cfix == limit) {
// Position Open
lfs.write(lfsout);
mon.write(monc);
rfs.write(rfsout);
}

delay(hold);
}

Archive
HackADay.io - FollowTV
Imgur - imgur.com/gallery/XbKaLmx
@HackADay - twitter.com/hackaday/status/652597228264161280
TVShow S01E06 Post


Count the pixels.
Written, Directed and A Salted by TVMiller
Filmed through a slice of ham gently placed over a ZTE N800
Magnetic Experiment 001


Imgur Mouse


Imgur - Imgur Mouse
Coke Shot
Addictions are absolute. How perverse they are can depend on your character. Alcohol, heroin, feet. We here at TVMiller prefer the unhealthy consumption of Coca~Cola. When delving deeper in to methodology, we all quickly learn two superior qualities; the aluminum can and the short brief intensity (the ahh) of an initial taste. We attempted to confine those elements in to a machine that sources three methods of activation; a button, a remote control and Jacob, our developing artificial intelligence.





// CokeShot
// TVMiller

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

int red = 8;
int green = 9;
int pour = 10;

int timepour = 10000;
int timeend = 3000;

void setup() {

Serial.begin(9600);

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

irrecv.enableIRIn();

}

void loop() {

digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(pour, LOW);

// Jacob
if (Serial.available()) {
char ser = Serial.read();
switch (ser) {
case 'C':
coke();
break;
}
}
// Remote (Any)
else if (irrecv.decode(&results)) {
coke();
irrecv.resume();
}

}

void coke() {
digitalWrite(pour, HIGH);
digitalWrite(green, HIGH);
delay(timepour);
digitalWrite(pour, LOW);
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
delay(timeend);
}

Archive
HackADay.io - Coke Shot
Github - Arduino IRRemote Library