20
20
#include < ESP8266WiFi.h>
21
21
#include < FirebaseArduino.h>
22
22
23
- const int pin_grove =15 ;
24
- const int pin_vibrator =5 ;
25
- const int pin_light_sensor = A0;
26
- const int pin_led =12 ;
27
- const int pin_button =14 ;
28
- const int pin_fan =13 ;
23
+ const int pinGrove =15 ;
24
+ const int pinVibrator =5 ;
25
+ const int pinLightSensor = A0;
26
+ const int pinLed =12 ;
27
+ const int pinButton =14 ;
28
+ const int pinFan =13 ;
29
29
30
30
void setup () {
31
31
Serial.begin (9600 );
32
32
33
- pinMode (pin_grove , OUTPUT);
34
- digitalWrite (pin_grove , HIGH);
33
+ pinMode (pinGrove , OUTPUT);
34
+ digitalWrite (pinGrove , HIGH);
35
35
36
- pinMode (pin_vibrator , OUTPUT);
37
- pinMode (pin_light_sensor , INPUT);
38
- pinMode (pin_led , OUTPUT);
39
- pinMode (pin_button , INPUT);
40
- pinMode (pin_fan , OUTPUT);
36
+ pinMode (pinVibrator , OUTPUT);
37
+ pinMode (pinLightSensor , INPUT);
38
+ pinMode (pinLed , OUTPUT);
39
+ pinMode (pinButton , INPUT);
40
+ pinMode (pinFan , OUTPUT);
41
41
42
42
// connect to wifi.
43
43
WiFi.begin (" SSID" ," PASSWORD" );
@@ -57,15 +57,15 @@ int button = 0;
57
57
float light =0.0 ;
58
58
59
59
void loop () {
60
- digitalWrite (pin_led , (int )Firebase.get (" redlight" ));
61
- digitalWrite (pin_fan , (int )Firebase.get (" cooldown" ));
62
- digitalWrite (pin_vibrator , (int )Firebase.get (" brrr" ));
63
- int newButton =digitalRead (pin_button );
60
+ digitalWrite (pinLed , (int )Firebase.get (" redlight" ));
61
+ digitalWrite (pinFan , (int )Firebase.get (" cooldown" ));
62
+ digitalWrite (pinVibrator , (int )Firebase.get (" brrr" ));
63
+ int newButton =digitalRead (pinButton );
64
64
if (newButton != button) {
65
65
button = newButton;
66
66
Firebase.set (" pushbutton" , button);
67
67
}
68
- float newLight =analogRead (pin_light_sensor );
68
+ float newLight =analogRead (pinLightSensor );
69
69
if (abs (newLight - light) >100 ) {
70
70
light = newLight;
71
71
Firebase.set (" sunlight" , light);