Sending SMS after 4 different buttons have been pressed

Hi long story short I am currently working on a project at uni and we are making a vending machine, one of the features is to make the vending machine text us when 4 of the items have been vended signalling that the 'stock is low and needs refilling'.

I have a gsm board (Seimens TC35), till now I have managed to send an SMS to my phone but not with the code for the buttons attached, also the text only sends by pressing the reset button on the arduino which is very weird and would like to find a solution to this.

Aims:

  • Have the arduino know when 4 different buttons have been pressed then send a Text to my phone
  • Have the arduino send the text without the reset button needing to be pressed.

Here is the current code I have used to send a text to my phone:

char phone_no[]="07123456789"; void setup() { Serial.begin(9600); delay(5000); Serial.print("AT+CMGF=1\r");//sets arduino to text mode delay(1000); Serial.println("AT+CMGS=\"07123456789\"");//phone number to text Serial.print(phone_no); delay(1000); Serial.print("Your vending machine stock is low");//message goes here Serial.println((char)26); } void loop() { }

I am fairly new with coding, your help is much appreciated,

Many thanks.

char phone_no[]="07123456789";

void setup() {  // Executes once after Reset
    Serial.begin(9600);
}

void loop() {  // Runs repeatedly forever
    static boolean button5StockIsFreshlyLow = false;

    if (button5StockIsFreshlyLow) {
        reportLowStock(5);
        button5StockIsFreshlyLow = false;
    }
}

void reportLowStock(int button) {
    delay(5000);
    Serial.print("AT+CMGF=1\r");//sets GSM to text mode
    delay(1000);
    Serial.print("AT+CMGS=\"");
    Serial.print(phone_no);    //phone number to text
    Serial.println("\"");
    delay(1000);
    // message goes here
    Serial.print("Your vending machine button ")
    Serial.print(button);
    Serial.print(" stock is low");
    Serial.println((char)26);
}
Serial.print("AT+CMGF=1\r");//sets arduino to text mode

Nonsense. That is doing NOTHING to the Arduino.

Thank you i will try this out, i will inform you of my progress