I am unable to get the code to run more than once.

Hi there,

I am new to arduino and have a question regarding the code attached below.

The purpose of the code is to send and SMS message to a phone when a microswitch is activated by the user. At the minute, an SMS message IS sent to the phone when the switch is activated but it only happens once. If the switch is then activated again an SMS message IS NOT sent to the phone, unless I go and reupload the code to the arduino.

Ideally, I would like an SMS message to be sent to the phone every time the switch is activated, without having to go back in and re upload the code to the arduino every time.

ANY help is greatly appreciated, thanks :slight_smile:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
  while (!Serial) {;}
  Serial.println("Goodnight moon!");
        while (digitalRead(2) ==  HIGH) {;}
      mySerial.write("AT+CMGF=1"); mySerial.println();
      mySerial.write("AT+CMGS="); mySerial.write('"'); mySerial.write("07453269526"); mySerial.write('"'); mySerial.println();
      mySerial.write("Flat 56.");

void loop() { 
  if (mySerial.available()) {
  if (Serial.available()) {

Post code using code tags.

NOT photos.