hi
im trying to modify a code i get to use it for one porpuse
so the idea is a push botton is (nc) in stand bye and no message is send is button is pressed mensage is send this part is rworking the problem is that if the button stays pressed and it will stay a lot of mensages is send.
the type of solucion i thick works
button pressed send only 1 comand until the button is off and on again
can someone help me with the code
code
#include <SoftwareSerial.h>
SoftwareSerial sim800l(2, 3); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted
#define button1 7 //Button pin, on the other pin it's wired with GND
bool button_State; //Button state
void setup()
{
pinMode(button1, INPUT_PULLUP); //The button is always on HIGH level, when pressed it goes LOW
sim800l.begin(9600); //Module baude rate, this is on max, it depends on the version
Serial.begin(9600);
delay(1000);
}
void loop()
{
button_State = digitalRead(button1); //We are constantly reading the button State
if (button_State == HIGH) { //And if it's pressed
Serial.println("botao on"); //Shows this message on the serial monitor
delay(200); //Small delay to avoid detecting the button press many times
SendSMS(); //And this function is called
}
if (sim800l.available()){ //Displays on the serial monitor if there's a communication from the module
Serial.write(sim800l.read());
}
}
void SendSMS()
{
Serial.println("Sending SMS...");
sim800l.print("AT+CMGF=1\r"); //Set the module to SMS mode
delay(100);
sim800l.print("AT+CMGS=\",,,,,\"\r"); //phone number
delay(500);
sim800l.print("1"); //mensage send
delay(500);
sim800l.print((char)26);
delay(500);
sim800l.println();
Serial.println("Text Sent.");
delay(500);
}