-
Notifications
You must be signed in to change notification settings - Fork 5
/
Test.ino
53 lines (42 loc) · 985 Bytes
/
Test.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
#include "./IMU.h"
#include "./SD.h"
#include "./Servo.h"
#include "./Camera.h"
void setup()
{
// Wire(Arduino-I2C)の初期化
Wire.begin();
// デバック用シリアル通信は9600bps
Serial.begin(9600);
//SD_Init(); // これは絶対最初に初期化!
//CAM_Init(); // SDの後!
IMU_Init();
//SRV_Init();
Serial.println(F("Init done"));
delay(300);
}
void loop()
{
while (1) {
IMU_UpdateAll();
int mag_x=IMU_GetMagX();
int mag_y=IMU_GetMagY();
Serial.println(mag_x);
Serial.println(mag_y);
float magnet_radian=atan2((float)mag_y,(float)mag_x);
float magnet_degree=magnet_radian*180.0/PI;
Serial.print(F("Direction: "));
Serial.print(magnet_degree);
Serial.println(F("[deg]"));
if (magnet_degree<30&&magnet_degree>-30){
Serial.println("kita");
break;
}
delay(1000);
}
CAM_TakePic(); // 写真を撮る
delay(1000);
Serial.println(F("END"));
while (1) {
}
}