Model: SW-420 Dimensions: 1.50 in x 0.51 in x 0.28 in (3.8 cm x 1.3 cm x 0.7 cm)
Single chip test program / ****************************************** Sensor trigger test Microcontroller: STC89C52 Baud rate: 9600 Product use: vibration sensor trigger, alarm trigger. ***************************************** / #include Unsigned char date #define uchar unsigned char #define uint unsigned int Sbit key1 = P0 ^ 1;
/ * Function statement ---------------------------------------------- - * / Void delay (uint z); Void Initial_com (void); // ************************************************ *********** / * ************************************************** ****************************** ** Function name: delay (uint z) ** Function: Delay function ************************************************** ****************************** * / Void delay (uint z) { Uint i, j For (i = z; i> 0; i--) For (j = 110; j> 0; j--); }
// ****************************** // ***** serial port initialization function *********** // ****************************** Void Initial_com (void) { EA = 1; // open total interrupt ES = 1; // allow serial interrupt ET1 = 1; // allows timer T1 to be interrupted TMOD = 0x20; // Timer T1, the mode 2 interrupt generates the baud rate PCON = 0x00; // SMOD = 0 SCON = 0x50; // mode 1 is controlled by a timer TH1 = 0xfd; // The baud rate is set to 9600 TL1 = 0xfd; TR1 = 1; // On timer T1 runs the control bit }
/ / ************************* // ********** main function ********* // ************************* Main () { Initial_com (); While (1) {
If (key1 == 1) { Delay (); If (key1 == 1) // confirm the trigger { SBUF = 0X01; Delay (200);
}
}
If (RI) { Date = SBUF; // accept the microcontroller SBUF = date; // send the microcontroller RI = 0; } |
For enquiries please Whatsapp 0125374838
https://wa.me/60125374838
5 star |
|
0 |
4 star |
|
0 |
3 star |
|
0 |
2 star |
|
0 |
1 star |
|
0 |