Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <TelegramBot.h>
- #include <WiFiSSLClient.h>
- #include <WiFi101.h>
- #include <SPI.h>
- String id = "xxxxxxxx";
- char ssid[] = "Vodafone-34374xxx";
- char pass[] = "uevyxxxxxxxxxxx";
- const char BotToken[] = "409478169:xxxxxxxE7SfmUjp2F2_Cr4-SvFxuo";
- const char BotName[] = "Apriti Sesamo";
- const char BotUsername[] = "@xxxx_bot";
- WiFiSSLClient client;
- TelegramBot bot(BotToken, client);
- int portone=3;
- int porta=4;
- void setup() {
- // put your setup code here, to run once:
- pinMode(7, OUTPUT);
- pinMode(portone, OUTPUT);
- pinMode(porta, OUTPUT);
- digitalWrite(portone, HIGH);
- digitalWrite(porta, HIGH);
- Serial.begin(115200);
- Serial.print("Connecting");
- while(WiFi.begin(ssid, pass) == WL_CONNECTED){
- Serial.print(".");
- delay(250);
- }
- Serial.print("\n\nConnesso");
- bot.begin();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- start:
- message m = bot.getUpdates();
- if(m.text.equals("/start")){
- bot.sendMessage(m.chat_id, "Ciao, per aprire le porte digitare \"/apri\"");
- m.text="";
- goto start;
- }
- if(m.text.equals("/apri")){
- if(m.chat_id==id||m.chat_id=="19xxxxxx"){
- digitalWrite(portone, LOW);
- delay(50);
- digitalWrite(portone, HIGH);
- bot.sendMessage(m.chat_id, "Portone aperto");
- digitalWrite(porta, LOW);
- delay(50);
- digitalWrite(porta, HIGH);
- bot.sendMessage(m.chat_id, "Porta aperta");
- m.text="";
- goto start;
- }
- else{
- bot.sendMessage(m.chat_id, "Non sei autorizzato ad aprire le porte");
- m.text="";
- goto start;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement