Created
January 13, 2017 17:56
-
-
Save carter-yagemann/86b4922dde7438c3d40e4b0bd82b600d to your computer and use it in GitHub Desktop.
Turn on computer using Internet of Things
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mobo Power - Copyright 2015 Carter Yagemann | |
* | |
* This program allows a core to power on a motherboard over the internet! | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
*/ | |
void setup() { | |
// D0 will control the motherboard | |
pinMode(D0, OUTPUT); | |
// ATX boards maintain high power on their power pin and then ground | |
// shortly to signal that the motherboard should power up. So we | |
// normally want the pin to be in the high state. | |
digitalWrite(D0, HIGH); | |
// Register a function with Particle's cloud service so we can invoke | |
// the core from over the internet. | |
Spark.function("poweron", powerOn); | |
} | |
void loop() { | |
// Nothing to do | |
} | |
int powerOn(String command) { | |
// Switch the pin to low for half a second so the motherboard knows | |
// it's time to turn on. | |
digitalWrite(D0, LOW); | |
delay(500); | |
digitalWrite(D0, HIGH); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment