Roger Alvarez
Published © LGPL

The Control-inator

A small device that allows you to push the physical buttons on your tv from your phone

BeginnerShowcase (no instructions)2 hours3
The Control-inator

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Photon 2
Particle Photon 2
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Apple Shortcut

Hand tools and fabrication machines

Tape, Scotch
Tape, Scotch

Story

Read more

Code

Button pusher

C/C++
Makes the servos turn and hit the buttons when event is triggered
// Include Particle Device OS APIs
#include "Particle.h"

// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);

// Show system, cloud connectivity, and application logs over USB
// View logs with CLI using 'particle serial monitor --follow'
SerialLogHandler logHandler(LOG_LEVEL_INFO);
Servo myServo;
Servo myServo2;
Servo myServo3;
int control = 0;
String Input[9] = {"tv","hdmi1","switch","playstation","hdmi4","wii","360","component2","pc"};
int curInput = 0;
// setup() runs once, when the device is first turned on
void setup() {
    // Put initialization like pinMode and begin functions here
    myServo.attach(1);
    myServo2.attach(A2);
    myServo3.attach(A5);
    Particle.function("Off",OffButton);
    Particle.function("On",OnButton);
    Particle.function("UpOne",Volume1);
    Particle.function("UpFive",Volume5);
    Particle.function("Switch",Switch);
    Particle.function("Ps4",PlayStation);
    Particle.function("Wii",Wii);
    Particle.function("Xbox360",Xbox);
    Particle.function("InputReset",Tv);
    myServo.write(10);
    myServo2.write(10);
    myServo3.write(70);
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
    /*if(control == 1){
        myServo.write(50);
        delay(1000);
        myServo.write(10);
        control = 0;
    }else if(control == 2){
        myServo2.write(50);
        delay(1000);
        myServo2.write(10);
        control = 0;
    }*/
}

int OffButton(String j){
    Tv("");
    myServo.write(55);
    delay(1000);
    myServo.write(10);
    return 0;
}

int Tv(String j){
    IntialPush();
    while(Input[curInput]!="tv"){
        myServo3.write(10);
        delay(500);
        myServo3.write(70);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}

int Xbox(String j){
    IntialPush();
    while(Input[curInput]!="360"){
        myServo3.write(10);
        delay(500);
        myServo3.write(70);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}

int Wii(String j){
    IntialPush();
    while(Input[curInput]!="wii"){
        myServo3.write(10);
        delay(500);
        myServo3.write(70);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}

int PlayStation(String j){
    IntialPush();
    while(Input[curInput]!="playstation"){
        myServo3.write(10);
        delay(500);
        myServo3.write(70);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}

int Switch(String j){
    IntialPush();
    while(Input[curInput]!="switch"){
        myServo3.write(10);
        delay(500);
        myServo3.write(70);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}

/*int PlayStation(String j){
    int rep=0;
    int subInput = curInput;
    while(input(subInput)!="playstation"){
        rep++;
        subInput++;
        if(subInput == 9){
        subInput = 0;
        }
    }
    IntialPush();
    for(i=0;i<rep;i++){
        myServo3.write(50);
        delay(500);
        myServo3.write(10);
        delay(500);
        curInput++;
        Reset();
    }
    return 0;
}*/

int OnButton(String j){
    myServo.write(55);
    delay(1000);
    myServo.write(10);
    return 0;
}

int Volume1(String j){
    myServo2.write(50);
    delay(1000);
    myServo2.write(10);
    return 0;
}
int Volume5(String j){
    for(int i=0;i<5;i++){
        myServo2.write(50);
        delay(1000);
        myServo2.write(10);
        delay(1000);
    }
    return 0;
}

void Reset(){
    if(curInput == 9){
        curInput = 0;
    }
}

void IntialPush(){
    myServo3.write(10);
    delay(1000);
    myServo3.write(70);
    delay(500);
}

Credits

Roger Alvarez
1 project • 0 followers

Comments