Reputation: 1
I provided a code that calls a specific number upon executing and uploading it to the microprocessor. I want it to call five different numbers simultaneously at a period of time(3 minutes).
#include <SoftwareSerial.h>
SoftwareSerial sim(10, 11);
// Define an array of phone numbers
String numbers[] = {
"+639*********", // Change with your first number
"+639*********", // Change with your second number
"+639*********", // Change with your third number
"+639*********", // Change with your fourth number
"+639*********" // Change with your fifth number
};
int selectedNumber = -1; // Index of the selected number, initially set to -1
int ledPin = 9; // Define the LED pin
void setup() {
Serial.begin(9600);
Serial.println("System Started...");
sim.begin(9600);
pinMode(ledPin, OUTPUT); // Set the LED pin as an OUTPUT
digitalWrite(ledPin, LOW); // Initially turn off the LED
delay(1000);
Serial.println("Type a number (1-5) to call the corresponding contact");
}
void loop() {
if (Serial.available() > 0) {
char input = Serial.read();
int numericInput = input - '0'; // Convert the character to an integer
if (numericInput >= 1 && numericInput <= 5) {
selectedNumber = numericInput - 1; // Adjust to 0-based index
callNumber();
} else {
Serial.println("Invalid input. Type a number from 1 to 5 to call a contact.");
}
}
}
void callNumber() {
if (selectedNumber >= 0 && selectedNumber < 5) {
sim.print(F("ATD"));
sim.print(numbers[selectedNumber]);
sim.print(F(";\r\n"));
digitalWrite(ledPin, HIGH); // Turn on the LED when making the call
delay(1000); // Call will last for 2 minutes (1000 milliseconds)
}
}
Upvotes: 0
Views: 53