blob: 284a2a1a06cf29a9136fd3d00875b5f29fe15e9f (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#include "Belt.h"
#include "logs.h"
Belt::Belt()
{
_pin_pressure_bottom = 0;
_pin_pressure_top = 1;
_pin_flexion = 2;
_pin_gyro_x = 3;
_pin_gyro_y = 4;
_pin_gyro_z = 5;
}
void Belt::read_pressure_top()
{
_pressure_top = analogRead(_pin_pressure_top);
}
void Belt::read_pressure_bottom()
{
_pressure_bottom = analogRead(_pin_pressure_bottom);
}
void Belt::read_flexion()
{
_flexion = analogRead(_pin_flexion);
}
void Belt::read_angle_x()
{
_angle_x = analogRead(_pin_gyro_x);
}
void Belt::read_angle_y()
{
_angle_y = analogRead(_pin_gyro_y);
}
void Belt::read_angle_z()
{
_angle_z = analogRead(_pin_gyro_z);
}
static Belt belt;
void setup()
{
Serial.begin(9600);
}
static void send_pressure_bottom(int pressure)
{
serial_printf("PRESSURE_BOTTOM:%d\n", pressure);
}
static void send_pressure_top(int pressure)
{
serial_printf("PRESSURE_TOP:%d\n", pressure);
}
static void send_flexion(int flexion)
{
serial_printf("FLEXION:%d\n", flexion);
}
static void send_angle_x(int angle)
{
serial_printf("ANGLE_X:%d\n", angle);
}
static void send_angle_y(int angle)
{
serial_printf("ANGLE_Y:%d\n", angle);
}
static void send_angle_z(int angle)
{
serial_printf("ANGLE_Z:%d\n", angle);
}
void loop()
{
delay(500);
/* fetch the values from the sensors */
belt.read_pressure_bottom();
belt.read_pressure_top();
belt.read_flexion();
belt.read_angle_x();
belt.read_angle_y();
belt.read_angle_z();
serial_printf("PRESSURE_BOTTOM: bottom:%d\n", belt.get_pressure_bottom());
serial_printf("PRESSURE_TOP:%d\n", belt.get_pressure_top());
serial_printf("FLEXION:%d\n", belt.get_flexion());
serial_printf("ANGLE_X:%d\n", belt.get_angle_x());
serial_printf("ANGLE_Y:%d\n", belt.get_angle_y());
serial_printf("ANGLE_Z:%d\n", belt.get_angle_z());
}
|