Initial commit.
This commit is contained in:
commit
13f7706782
5 changed files with 221 additions and 0 deletions
53
readme.md
Normal file
53
readme.md
Normal file
|
@ -0,0 +1,53 @@
|
|||
# Control a transistor with a webhook
|
||||
|
||||
This is an Arduino IDE sketch for a "smart" controller that can activate pins
|
||||
based on the state of some webpage. The motivating use cases are:
|
||||
|
||||
* Controlling a PC power switch remotely, using a transistor wired to the power switch pins
|
||||
* Lighting specific LEDs to create a remotely controlled 'traffic light'.
|
||||
|
||||
This sketch currently targets only the ESP8266, and will probably not work with other
|
||||
microcontrollers. Support for other boards may come if I run out of ESP8266's.
|
||||
|
||||
## Configuration
|
||||
|
||||
First:
|
||||
|
||||
```
|
||||
cp config.h.example config.h
|
||||
```
|
||||
|
||||
Then edit `config.h` and fill in the correct values for your environment.
|
||||
|
||||
`PIN_MAP` in `config.h` is an array of pins that we want to control. Each item in the array is itself an
|
||||
array, with the following format:
|
||||
|
||||
```
|
||||
[output_pin, control_mode]
|
||||
```
|
||||
|
||||
The index of the item in the top-level array is its 'index' value in the webhook. (see webhook data, below)
|
||||
|
||||
`output_pin` is obviously the pin to control.
|
||||
|
||||
`control_mode` is either 0 or 1. 0 is for momentary mode; that is, when the state is active the pin will
|
||||
only be high for a short time. 1 is for latched mode; the pin will stay high until the state changes.
|
||||
|
||||
|
||||
|
||||
## Building
|
||||
|
||||
**TODO**
|
||||
|
||||
|
||||
## Webhook data
|
||||
The webhook should always return a page in the following format:
|
||||
|
||||
```
|
||||
index_0 state_0
|
||||
index_1 state_1
|
||||
...
|
||||
```
|
||||
|
||||
Where index and state are both integers. If you are expecting momentary input, you should return the
|
||||
state to '0' after the page is served / the webhook is consumed.
|
Loading…
Add table
Add a link
Reference in a new issue