-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeMcu_sterowanie_winda.ino
60 lines (49 loc) · 1.26 KB
/
NodeMcu_sterowanie_winda.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
/*
Name: NodeMcu_sterowanie_winda.ino
Created: 6/28/2022 10:02:38 PM
Author: wojci
*/
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <Adafruit_PWMServoDriver.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <IRremote.hpp>
//#define led D1
volatile bool status = false;
#include "Sterowanie_Servo.h"
#include "BT.h"
#include "IR.h"
#include "MQTT.h"
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
setup_BT();
setup_IR();
pinMode(LED_BUILTIN, OUTPUT);
delay(100);
Serial.println("Rozpoczecie programu");
pwm.begin();
pwm.setOscillatorFrequency(27000000); //PCA9685 chip is a range between about 23-27MHz
pwm.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
int i;
for (i = 0; i < 10; i++) {
moveServo(0);
}
//MQTT
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
//set_sub_pub_mqtt();
}
// the loop function runs over and over again until power down or reset
void loop(){
sprawdzanie_bufora_BT();
if (status) {
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
status = false;
}
}