/**
* @file Whatsapp_Message.ino
* @author Hafidh Hidayat ([email protected])
* @brief Example WhatsApp Messages
*
* @copyright Copyright (c) 2022
*
* Github :
* https://github.com/hafidhh
* https://github.com/hafidhh/Callmebot-ESP32
*/
#include <WiFi.h>
#include <Callmebot_ESP32.h>
const int boton = 2;
int estado = 0;
int control = 0;
// Note :
// phoneNumber : Indonesia +62, Example: "+62897461238"
// apiKey : Follow instruction on https://www.callmebot.com/blog/free-api-whatsapp-messages/
String phoneNumber = "+573113606620";
String apiKey = "9461394";
String message = "Mauricio";
void setup() {
Serial.begin(115200);
pinMode(boton, INPUT);
Serial.print("Conectando-se ao Wi-Fi");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println(" Conectado!");
}
void loop() {
estado = digitalRead(boton);
if (estado == LOW){
control++;
Serial.print("BOTON : ");
Serial.println(control);
delay(200);
switch (control){
case 1: message = "hola";
break;
case 2: message = "pelota";
break;
case 3: message = "sandra";
control = 0;
break;
}
Serial.print("enviar");
Callmebot.whatsappMessage(phoneNumber, apiKey, message);
Serial.println(Callmebot.debug());
}
}