added double buffering to prevent tearning
[Arduino] / arduino_ebus / arduino_ebus.ino
1 /*
2  * http://ebus-wiki.org/lib/exe/fetch.php/ebus/arduinoebus.pdf
3  * 
4  * I had to increase values to 47k and 10k on Vaillant boiler so that it doesn't
5  * draw 22V line down to 9V
6  * 
7  * A0 --*--[47k]--- EBUS+
8  *      |
9  *    [10k]
10  *      |
11  * GND -*------------ EBUS-     
12  * 
13  * D13 -> serial RX -> D1
14  */
15
16 int in=A0;
17 int out=13;
18
19 int treshold = ((9.0*1023.0)/20.02);
20
21 void setup() {
22   pinMode(in, INPUT);
23   pinMode(out, OUTPUT);
24 //  Serial.begin(2400);
25   pinMode(0, INPUT);
26   pinMode(1, INPUT);
27 }
28
29 void loop() {
30   int inputvalue = analogRead(in);
31   if (inputvalue > treshold)
32     digitalWrite(out,1);
33   else
34     digitalWrite(out,0);
35 }