Examples | Shop
 
Intruder Alert using the Brainstem™ Microcontroller,
DS-PRX and DSLCDD2
 
 
The following example application demonstrates the use of a DS-PRX infrared motion sensor and DS-LCDD2 IIC 20x2 character LCD module interfaced with the Brainstem™ microcontroller.
It incorporates the updated Brainstem aLCDx.tea Library file for use with the DS-LCDD2 LCD. (The aLCDx.tea can be found here and should be saved in the Brainstem/aSystem file).
An initial delay is set to allow the DS-PRX to settle (between 7 and 30 seconds). When the DS-PRX detects movement, the resulting analogue signal is read by the Brainstem.
If the signal is less than the specified trigger number, the green LED lights and a “Scanning, All Clear” screen is displayed on the LCD.
If the trigger number is greater, the red LED lights and a “Warning, Alarm Triggered” screen is displayed. This will remain until the DS-PRX drops to a low set trigger level.
During this process, if the Brainstem is connected to the console, the analogue number from the DS-PRX can be read as a number on screen. This is useful to set trigger detection levels.
Brainstem is a Trademark of Acroname Inc.

 

/* Description: Intruder alert using DS-PRX Passive Infrared Motion Sensor and DS-LCDD2 IIC LCD controlled by the Brainstem™ microcontroller.
Created: 16/09/02 Revision 3.00
Written by:Total Robots (Jamie Finnan)
TR-005
Brainstem™ is a registered trademark of Acroname Inc
*/
/* Description: Intruder alert using DS-PRX Passive Infrared Motion Sensor
and DS-LCDD2 IIC LCD controlled by the Brainstem microcontroller.
Created: 16/09/02 Revision 2.00
Written by:Total Robots (Jamie Finnan)
TR-009
*/
#include <aA2D.tea> //Setup aA2D.tea file for use
#include <aCore.tea> //Setup aCore.tea file for use
#include <aDig.tea> //Setup aDig.tea file for use
#include <aPrint.tea> //Setup aPrint.tea file for use
#define ALCD_ADDR 40 //setup the LCD address before aLCDx.tea
#include <aLCDx.tea> //setup aLCDx.tea file for use
//*******************************************************************
void main()
{
aCore_Sleep (1000); //small delay for brainstem bootup
aDig_Config(0,ADIG_OUTPUT); //configure digital output on pin 0
aDig_Config(1,ADIG_OUTPUT); //configure digital output on pin 1
aLCDx_Cmd(1);
aLCDx_String(" Initialising ");
aLCDx_Cmd((unsigned char)192);
aLCDx_String("Please Wait.........");
aCore_Sleep (30000); //delay for IR sensor to settle
aCore_Sleep (30000); //delay for IR sensor to settle
aCore_Sleep (30000); //delay for IR sensor to settle
aCore_Sleep (30000); //delay for IR sensor to settle
again(); //call subroutine 'again'
}//********************************************************************
void again() //subroutine 'again'
{
int IR; //set up IR as 10 bit store
IR = aA2D_ReadInt(4); //IR = value of IR sensor at analogue 4
while (IR>0) //loop consturct
{
IR = aA2D_ReadInt(4); //IR = value of IR sensor at analogue 4
if(IR<700) //If IR value is less than 700
{
led2(); //call subroutine led2
}
else
{
led1(); //call subroutine led1
}
aPrint_IntDec(IR); //This diplays the IR value on the
aPrint_Char('\n'); //console screen
aCore_Sleep (10000); //It is not needed when running
} //seperate from the console.
}
//********************************************************************
void led1() //Subroutine led1
{
aDig_Write(0,0); //set digital pin 0 to 0
aDig_Write(1,1); //set digital pin 1 to 1
aLCDx_Cmd(1); //clear screen
aLCDx_String(" Warning Warning ");
aCore_Sleep(5000); //0.5 sec delay
aLCDx_Cmd(1); //clear screen
aCore_Sleep(5000); //0.5 sec delay
aLCDx_String(" Warning Warning ");
aCore_Sleep(5000); //0.5 sec delay
aLCDx_Cmd(1); //clear screen
aCore_Sleep(5000); //0.5 sec delay
aLCDx_String(" Warning Warning ");
aCore_Sleep(5000); //0.5 sec delay
aLCDx_Cmd((unsigned char)192); //send cursor to second line
aLCDx_String(" Alarm Triggered ");
aCore_Sleep(30000); //3 sec delay
aLCDx_Cmd(1); //clear screen
}
//********************************************************************
void led2() //subroutine led2
{
aDig_Write(0,1); //set digital pin 0 to 1
aDig_Write(1,0); //set digital pin 1 to 0
aCore_Sleep (1000); //short settling delay
aLCDx_Cmd(1); //clear screen
aLCDx_String(" Scanning ");
aCore_Sleep(5000); //0.5sec delay
aLCDx_Cmd(1); //clear screen
aCore_Sleep(5000); //0.5sec delay
aLCDx_String(" Scanning ");
aCore_Sleep(5000); //0.5sec delay
aLCDx_Cmd((unsigned char)192); //send cursor to second line.
aLCDx_String(" All Clear ");
} //End of program!
//********************************************************************
//********************************************************************


Examples | Shop