Model: SW-420
- Material: PCB board
- Working voltage: 3.3V~5V
- Current: > 15mA
- Uses SW-420 normally closed vibration sensor module
- Digit switch output: 0, 1
- Uses LM393 comparator
- Green light on when vibration switch is under closed conduction state and the output terminal is low
- Green light off when vibration switch is disconnected and the output terminal is high 
- Great for microcontroller experiment
- Output terminal can be connected to microcontroller to test electric level and if the environment is in vibration, alarm function
- Suitable for a variety of vibration triggering functions, theft alarm, smart car, earthquake alarm, motorcycle alarm, etc.

 

Dimensions: 1.50 in x 0.51 in x 0.28 in (3.8 cm x 1.3 cm x 0.7 cm)
Weight: 0.18 oz (5 g)

 

 

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;

}