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() {
  Serial.begin(9600);
  while (!Serial) {;}
  Serial.println("Goodnight moon!");
  mySerial.begin(4800);
        pinMode(2,INPUT_PULLUP);
        while (digitalRead(2) ==  HIGH) {;}
      mySerial.write("AT+CMGF=1"); mySerial.println();
      delay(100);
      mySerial.write("AT+CMGS="); mySerial.write('"'); mySerial.write("07453269526"); mySerial.write('"'); mySerial.println();
      delay(100);
      mySerial.write("Flat 56.");
    mySerial.println(char(26));
}

void loop() { 
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Post code using code tags.

NOT photos.