Capture phone number from contact form

Form number can be written in various forms, with (), with – or with + sign. Instead of asking for a seperate field in contact form, you can capture it from withing text form  using regex.


Regex for Phone number: [\d\(\)\+\- ]{7,}

Explanation of Regex pattern: It basically means,  find a group that contains digit, (,),+,- or space and which is at least 7 characters long. This will roughly equate to phone number in the contact form.

Posted in Uncategorized | Leave a comment

LCD Display Manufacturers

The following are popular LCD Display manufacturers, some are cheap, other are expensive

Newhaven Displays

Orient Displays

Midas Displays


Posted in Uncategorized | Leave a comment

My Shortcode Buttons

color full button


Posted in Uncategorized | Leave a comment

Cannot find plib.h MPLAB X IDE


I had copied a project that was builder in older MPLAB X IDE 3.x which I was opening in freshly installed MPLAB X IDE 4.05 but it was complaining about not find plib.h library which was referenced in the code.

I did a couple of days of digging into and now found the problem using this microchip form post, which says

The installer “PIC32 Legacy Peripheral Libraries – Windows” from here
asks for the installation directory during installation, even if you have only one XC32 version installed.
In my case it proposes: C:\Program Files (x86)\Microchip\xc32\v1.40
which is “wrong”, because I only have v1.43 installed.

I.e. it proposed the wrong directory, and if you simply accept, it will use that wrong path.
As a consequence you cannot use the peripheral library (without changing project paths)

Install it again into your “current” compiler directory.
I could imagine its a bug, but they won’t fix it for the legacy PLIB.

which was exactly the problem. The problem was older version of MPLAB X IDE uses legacy drivers (plib) while they have been abandoned in the newer version. Verse legacy drivers are not shipped with the latest version of MPLAX X 4.05.

To sum up the problem for a newbie, to make older code work in the latest MPLAB X, you have to do the following.

  1. Install MPLAB X V4.05 (latest by today)
  2. Intall X32 C-Compiler (you have to download this sperate)
  3. Install “PIC32 Peripheral LIbrary” (You have to download it first)
  4. When you install PIC32 Peripheral Library, it will try to install itself in XC32/1.40 folder but you have to change that. This is the trick that you have to apply. Simply supply it the path to XC32 folder, which must already exist and continue with the installation.

That should solve your problem of “not finding plib.h” which is the peripheral library for legacy (older) MPLAB.

Posted in Uncategorized | Leave a comment

Send SMS via C# Code GSM Module

2018-01-03 16_55_12-Form1

The following is the code that you need to send SMS through C# code. Note, this code goes in to Send button click function handler.


private void btnSend_Click(object sender, EventArgs e)
SerialPort sp = new SerialPort();
sp.PortName = txtPort.Text;
sp.WriteLine(“AT” + Environment.NewLine);
sp.WriteLine(“AT+CMFG=1” + Environment.NewLine);
sp.WriteLine(“AT+CSCS=\”GSM\”” + Environment.NewLine);
sp.WriteLine(“AT+CMGS=\”” + txtPhone.Text + “\”” + Environment.NewLine);
sp.WriteLine(txtMessage.Text + Environment.NewLine);
sp.Write(new byte[] { 26 }, 0, 1);
var response = sp.ReadExisting();

if (response.Contains(“ERROR”))
MessageBox.Show(“SMS Failed”);
MessageBox.Show(“SMS Sent successfully”);
catch (Exception ex)


When I test this code, it does return successfully weather GSM Modem is connected or not so there is definitely something not right with it.

Posted in Uncategorized | Leave a comment

Simple Interrup Example MPLAB

The following code will run on MX320 32-bit microcontroller. Taken from “Programming 32-bit Micrcontroller in C”.

Note that certain lines were modified to make it work.

** Single Interrupt vector test

#include <p32xxxx.h>
#include <peripheral\int.h>
#include <plib.h>
#define _T2IE IEC0bits.T2IE
#define _T2IF IFS0bits.T2IF
#define _T2IP IPC2bits.T2IP
int count;
void __ISR( 0, ipl1) InterruptHandler( void)
_T2IF = 0;
} // interrupt handler
// 1. init timers
PR2 = 15;
T2CON = 0x8030;
// 2. init interrupts
_T2IP = 1;
_T2IE = 1;
// 3. main loop
while( 1);
} // main

Posted in Uncategorized | Leave a comment

Change device in MPLAB IDE

Go to configure menu and select device to change a difference device than already selected.

select or change device - MPLAB IDE v8.92

A dialogbox will appear that allows  you select/change your existing device.


Posted in Uncategorized | Leave a comment