Arduino controlled Intruder alert with Visual C++(Windows Form) as GUI.

Hello!

To start, me and my groupmates decided to make a intruder alarm using a PIR sensor for our College project. We haven’t started anything yet, as we want to confirm if our project can be possibly made.

So everything is based form a googled diagram and instructions:
(courtesy of circuitstoday.com)

and the arduino code:

#include<SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
int sensor=7; //The output of PIR sensor connected to pin 7
int push_switch=6; // push button switch connected to pin 6
int buzzer=8; // buzzer connected at pin 8
int sensor_value; //variable to hold read sensor value
int sms_count=0;
void setup()
{
pinMode(sensor,INPUT); // configuring pin 7 as Input
pinMode(push_switch,INPUT); // configuring pin 6 as Input
pinMode(buzzer,OUTPUT); // configuring pin 8 as OUTPUT
mySerial.begin(9600);
}

void loop()
{
Check_Burglar();// subroutine to check sensor status and activation of outputs
Check_Reset(); // subroutine to check if alarm reset switch pressed or not
}

void Check_Burglar()
{
sensor_value=digitalRead(sensor); // Reading sensor value from pin 7
if(sensor_value==HIGH) // Checking if PIR sensor sends a HIGH signal to Arduino
{
  digitalWrite(buzzer,HIGH); // Activating the buzzer 
  while(sms_count<3) //Number of SMS Alerts to be sent limited at 3
    {  
      SendTextMessage(); // Function to send AT Commands to GSM module
    }
}}

void Check_Reset()
{
if(digitalRead(push_switch==HIGH))// Checking if pushbutton was pressed 
{
digitalWrite(buzzer,LOW); // turning OFF the buzzer 
sms_count=0; // Reactivating the SMS Alert Facility
}}

void SendTextMessage()
{
  mySerial.println("AT+CMGF=1");    //To send SMS in Text Mode
  delay(1000);
  mySerial.println("AT+CMGS=\"+919495xxxxxx\"\r"); // change to the phone number you using 
  delay(1000);
  mySerial.println("Gas Leaking!");//the content of the message
  delay(200);
  mySerial.println((char)26);//the stopping character
  delay(1000);
  sms_count++;
}

Since our project requires a GUI we have made a rough sketch of what will it look like.

So my question is by using Windows form, will we be able to change some parts of the code of the arduino?

For examples:
1.) Clicking the on/off button will turn on/off the system.

2.) If we put the cellphone number in the cellphone number textbox. the “mySerial.println(“AT+CMGS=”+919495xxxxxx”\r")" of the code will change the number the where the arduino will send its alert.

3.) If you click Call button, instead of text it will call your phone number. Which changes the “void SendTextMessage()” code.

Will all that be possible in the Gui? If yes, give me some insights of how to make the code since we have a little knowledge in visual C. and If no, Do you have any suggestions to how can we make alternatives of the said functions of the GUI.

Thanks in advance :slight_smile:
PS: Sorry for the bad english :slight_smile:

It's interesting that you used exactly the same phrasing as another poster, (different username), earlier:-

me and my groupmates

Arduino smart light

Will all that be possible in the Gui? If yes, give me some insights of how to make the code since we have a little knowledge in visual C. and If no, Do you have any suggestions to how can we make alternatives of the said functions of the GUI.

This is an Arduino (C++) forum. There's no point in asking questions about C# GUI coding. You need a C# forum, to ask about serial communications in C#.

And you can't "change some parts of the code of the arduino" using the C# GUI app, but you can send serial comms that determines which code is executed.

If not a specialised Visual C# forum, perhaps you should have posted in the "Interfacing w/ Software on the Computer" section of these forums, instead of "Project Guidance". Maybe you could ask a moderator to move the thread for you. (And C# questions aren't really 100% suitable there either.)

Thank you sir. We can adjust to the language that we’ll use for the GUI. We can also use C++ if it would be better.

With that being said, will all of these be possible if ever? :slight_smile:

carlo990: Thank you sir. We can adjust to the language that we'll use for the GUI. We can also use C++ if it would be better.

With that being said, will all of these be possible if ever? :)

It's definitely possible. But you're still asking in the wrong place. Writing code for Windows serial communications is a whole different ballgame to writing serial code for an Arduino, whether you use C# or C++. You need to ask for help on the GUI app in an appropriate place, to have the best chance of getting help. An Arduino forum is not the best place.

And no one will write the code for you. You need to make a start, then ask for help when you strike problems. Surely there are plenty of Windows programming forums, whether for C++ or C#?