-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMain_Wakasa.ino
59 lines (46 loc) · 908 Bytes
/
Main_Wakasa.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
#include "./Servo.h"
#include "./Barometer.h"
uint16_t loop_count = 0;
void setup()
{
// Wire(Arduino-I2C)の初期化
Wire.begin();
// デバック用シリアル通信は9600bps
Serial.begin(9600);
SRV_Init();
BMP_Init();
Serial.println(F("Init done"));
delay(300);
}
void loop()
{
BMP_Update();
//BMP_Print
float Pressure = BMP_GetPressure();
Serial.print(F("Preassure: "));
Serial.println(Pressure);
float Pressure_at_sea_level = 102504.0;
float height = (Pressure_at_sea_level - Pressure) / 100*10;
Serial.print(F("Height:"));
Serial.println(height);
if (height>=3){
if (height<4) {
Serial.println(F("3-4"));
SRV_SetPosition(60);
SRV_Run();
}
}
else if (height>=2) {
if (height<3) {
Serial.println(F("2-3"));
SRV_SetPosition(120);
SRV_Run();
}
}
else if (height<2) {
Serial.println(F("-2 "));
SRV_SetPosition(180);
SRV_Run();
}
delay(1000);
}