
- Send to a friend
-
- Remove this product from my favorite's list.
- Add this product to my list of favorites.
No products added yet
Detailed Description:
Uses:
Temperature detection, temperature control sensors, the ambient temperature detection
Module Features:
Module for use
Sample code:
SCM test program
/ ******************************************
Sensors trigger test
SCM: STC89C52
Baud Rate: 9600
Usage: temperature detection.
***************************************** /
# Include <reg52.h>
unsigned char date;
# Define uchar unsigned char
# Define uint unsigned int
sbit key1 = P0 ^ 1;
/ * Function affirm ---------------------------------------------- - * /
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 interruption
ES = 1; / / enable serial interrupt
ET1 = 1; / / enable the timer T1 interrupt
TMOD = 0x20; / / timer T1, generated baud rate in Mode 2 Interrupt
PCON = 0x00; / / SMOD = 0
SCON = 0x50; / / Mode 1 is controlled by a timer
TH1 = 0xfd; / / set the baud rate to 9600
TL1 = 0xfd;
TR1 = 1; / / Timer T1 running control bits
}
/ / *************************
/ / ********** Main function *********
/ / *************************
main ()
{
Initial_com ();
while (1)
{
if (key1 == 0)
{
delay (); / / eliminate jitter
if (key1 == 0) / / confirm trigger
{
SBUF = 0X01;
delay (200);
}
}
if (RI)
{
date = SBUF; / / microcontroller accept
SBUF = date; / / MCU sends
RI = 0;
}
}
}