3 changed files with 89 additions and 1 deletions
@ -0,0 +1,59 @@ |
|||||
|
#include "BluetoothSerial.h" |
||||
|
|
||||
|
#define LED1_PIN 26 |
||||
|
#define LED2_PIN 27 |
||||
|
|
||||
|
String device_name = "ESP-LED-VasePrijmeni"; |
||||
|
BluetoothSerial SerialBT; |
||||
|
|
||||
|
void setup() { |
||||
|
Serial.begin(115200); |
||||
|
SerialBT.begin(device_name); |
||||
|
Serial.printf("Zarizeni \"%s\" spuštěno. \n",device_name.c_str()); |
||||
|
pinMode(LED1_PIN, OUTPUT); |
||||
|
pinMode(LED2_PIN, OUTPUT); |
||||
|
// zajištění vypnutí LED při zapnutí (restartu)
|
||||
|
digitalWrite(LED1_PIN, LOW); |
||||
|
digitalWrite(LED2_PIN, LOW); |
||||
|
} |
||||
|
|
||||
|
void loop() { |
||||
|
if (SerialBT.available()) { |
||||
|
String command = SerialBT.readStringUntil('\n'); |
||||
|
command.trim(); |
||||
|
|
||||
|
if(command.equalsIgnoreCase("1on")) { |
||||
|
digitalWrite(LED1_PIN, HIGH); |
||||
|
SerialBT.println("LED 1 zapnuta"); |
||||
|
} else if (command.equalsIgnoreCase("1off")) { |
||||
|
digitalWrite(LED1_PIN, LOW); |
||||
|
SerialBT.println("LED 1 vypnuta"); |
||||
|
} else if (command.equalsIgnoreCase("2on")) { |
||||
|
digitalWrite(LED2_PIN, HIGH); |
||||
|
SerialBT.println("LED 2 zapnuta"); |
||||
|
} else if (command.equalsIgnoreCase("2off")) { |
||||
|
digitalWrite(LED2_PIN, LOW); |
||||
|
SerialBT.println("LED 2 vypnuta"); |
||||
|
} else if (command.equalsIgnoreCase("on")) { |
||||
|
digitalWrite(LED1_PIN, HIGH); |
||||
|
digitalWrite(LED2_PIN, HIGH); |
||||
|
SerialBT.println("obe LED zapnuty"); |
||||
|
} else if (command.equalsIgnoreCase("off")) { |
||||
|
digitalWrite(LED1_PIN, LOW); |
||||
|
digitalWrite(LED2_PIN, LOW); |
||||
|
SerialBT.println("obe LED vypnuty"); |
||||
|
} else { |
||||
|
SerialBT.println("neznamy prikaz. Pouzij: 1on, 1off, 2on, 2off, on, off"); |
||||
|
} |
||||
|
} |
||||
|
delay(20); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,28 @@ |
|||||
|
#include <WiFi.h> |
||||
|
|
||||
|
const char* ssid = "VASE_WiFi"; |
||||
|
const char* password = "HESLO_OD_WiFi"; |
||||
|
|
||||
|
void setup() { |
||||
|
Serial.begin(115200); |
||||
|
delay(10); |
||||
|
|
||||
|
Serial.println(); |
||||
|
Serial.print("Pripojuji se k WiFi: "); |
||||
|
Serial.println(); |
||||
|
WiFi.begin(ssid,password); |
||||
|
|
||||
|
while(WiFi.status() != WL_CONNECTED) { |
||||
|
delay(500); |
||||
|
Serial.print("."); |
||||
|
} |
||||
|
|
||||
|
Serial.println(); |
||||
|
Serial.println("WiFi připojeno"); |
||||
|
Serial.print("IP adresa: "); |
||||
|
Serial.println(WiFi.localIP()); |
||||
|
|
||||
|
} |
||||
|
void loop(){ |
||||
|
|
||||
|
} |
Loading…
Reference in new issue