Andy
Published © GPL3+

Remote Controlled PC Power Button

A remote controlled power button for your PC!

BeginnerShowcase (no instructions)103
Remote Controlled PC Power Button

Things used in this project

Software apps and online services

Remote.it

Story

Read more

Schematics

Wiring Diagram

Code

Code for Photon

C/C++
This is the code that I'm using on my photon, note that you will also need to setup a webhook for this to work.
#include "Particle.h"
SYSTEM_MODE(AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_INFO);

int basePin = A1;
String lastArg = "";    // saved value

void setup() {
    pinMode(basePin, OUTPUT);
    digitalWrite(basePin, HIGH);
    Particle.function("powerButton", onOff);
}

void loop() {
    // not much here
}

// Cloud function - uses webhook
int onOff(String param) {
    // Save the arg
    lastArg = param;

    // if hibernate
    if (param.equals("Hibernate")) {
        digitalWrite(basePin, LOW);
        delay(50);
        digitalWrite(basePin, HIGH);
        return 1; // so works?
    }

    // if restart
    if (param.equals("Restart")) {
        digitalWrite(basePin, LOW);
        delay(2000);
        digitalWrite(basePin, HIGH);
        return 2;
    }

    //Log.info("Unknown arg: '%s'", param.c_str());
    return 0; // failure!!!
}

Credits

Andy
1 project • 0 followers

Comments