-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathRAK12015_Shock_801S.ino
59 lines (54 loc) · 1.23 KB
/
RAK12015_Shock_801S.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
@file RAK12015_Shock_801S.ino
@author rakwireless.com
@brief Setup and read values from a 801S sensor
@version 0.1
@date 2021-07-23
@copyright Copyright (c) 2021
**/
#include <Arduino.h>
#include "Wire.h"
#define SensorOutput WB_A1
uint8_t interrupt1Flag = 0;
void setup() {
// put your setup code here, to run once:
time_t timeout = millis();
Serial.begin(115200);
/* WisBLOCK 12015 Power On*/
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(300);
/* WisBLOCK 12015 Power On*/
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
//falling edge fires , triggers interrupt a1, and calls the interrupt flag function
pinMode(SensorOutput, INPUT);
attachInterrupt(SensorOutput, interruptHandle1, RISING);
Serial.println("RAK12015 test Example");
}
/*
* brief:The threshold of the sensor is determined by the resistance of the pull-up resistor.
* Now the pull-up resistance is 10K
*/
void loop() {
// put your main code here, to run repeatedly:
if (interrupt1Flag == 1)
{
Serial.println("Trigger vibration sensor");
interrupt1Flag=0;
}
delay(500);
}
void interruptHandle1(void)
{
interrupt1Flag = 1;
}