-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeEasyWorking.ino
81 lines (69 loc) · 2.22 KB
/
HomeEasyWorking.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//http://www.instructables.com/id/RF-315433-MHz-Transmitter-receiver-Module-and-Ardu/step3/Arduino-Virtual-Wire-Library/
#include <HomeEasyCtrl.h>
#include <Servo.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Turorial: http://www.instructables.com/id/Make-a-pushbutton-without-a-resistor/
const int BUTTON_PIN = 6;//2; // the number of the pushbutton pin
const int LED_PIN = 13; // the number of the LED pin
const int LED_PIN_HOME_EASY = 8;
const int TRANSMITTER_PIN = 4;//3; //https://funksteckdose.net/mit-microcontrollern-steuern
const int ONE_WIRE_BUS = 2;
const int SERVO_PIN = 9;//https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors?view=all
HomeEasyCtrl easy(TRANSMITTER_PIN,LED_PIN_HOME_EASY);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// variables will change:
int state = 2; //true=On, false=Off
int buttonState = 0; // variable for reading the pushbutton status
int counter = 0;
Servo servo1;
void setup() {
Serial.begin(9600);
helper2();
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_PIN, OUTPUT);
pinMode(LED_PIN_HOME_EASY, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN_HOME_EASY, INPUT);
//initialize the buttonPin as output
digitalWrite(BUTTON_PIN, HIGH);
setUpServo();
}
void setUpServo(){
pinMode(1,OUTPUT);
servo1.attach(SERVO_PIN); //analog pin 0
Serial.println("Ready");
}
// the loop function runs over and over again forever
void loop() {
//if tee is started
if(state==1){
Serial.println("Tee Started");
digitalWrite(LED_PIN,HIGH);
easy.deviceOn();
meassureTempreature();
rotateServo();
digitalWrite(LED_PIN,LOW);
easy.deviceOff();
Serial.println("Tee finished");
state=0;
} if(state==2) {
for(int i=0;i<10;i++){
easy.deviceOn();
delay(1000);
}
easy.deviceOff();
state=0;
Serial.println("Learning Finish");
}else {
//listening for button or serial input to start tee routine
buttonState = digitalRead(BUTTON_PIN);
int data = readingData();
if(data==1 || buttonState==LOW){
Serial.println("Input for Tee");
state=1;
}
}
}