-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelmet_part_tx.ino
64 lines (57 loc) · 1.43 KB
/
helmet_part_tx.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
60
61
62
63
64
#include <VirtualWire.h>
const int sw=1; // FSR SENSOR
int adc=0; // ALCOhOL SENSOR
void setup()
{
pinMode(sw, INPUT);
vw_set_tx_pin(12); // Sets pin D13 as the TX pin // RF TRANSMITTER PART
// vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
}
void loop()
{
const char *msg0 = "0";
const char *msg1 = "1";
const char *msg2 = "2";
const char *msg3 = "3";
const char *msg4 = "4";
const char *msg5 = "5";
float adcValue=0;
for(int i=0;i<10;i++)
{
adcValue+= analogRead(A0);
delay(10);
}
float v= (adcValue/10) * (5.0/1024.0);
float adc= 0.67 * v;
if (adc<0.7&&digitalRead(sw)==HIGH)
{
vw_send((uint8_t *)msg0, strlen(msg0));
vw_wait_tx();
delay(30); }
else
{
vw_send((uint8_t *)msg1, strlen(msg1));
vw_wait_tx();
}
if (adc>0.7)
{
vw_send((uint8_t *)msg2, strlen(msg2));
vw_wait_tx();
delay(30); }
if (adc<0.7)
{
vw_send((uint8_t *)msg3, strlen(msg3));
vw_wait_tx();
}
if (digitalRead(sw)==HIGH)
{
vw_send((uint8_t *)msg4, strlen(msg4));
vw_wait_tx();
delay(30); }
if (digitalRead(sw)==LOW)
{
vw_send((uint8_t *)msg5, strlen(msg5));
vw_wait_tx();
}
}