forked from cameron7702/iYashi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
47 lines (35 loc) · 896 Bytes
/
main.c
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
#include <Servo.h>
#include <PID.c>
#include <data.pb.h>
Servo myservo;
User user1;
int resistance;
void setup() {
myservo.attach(9);
myservo.watch(90);
suser1.set_name("Biff");
sensor.set_userid(1);
sensor.set_resistance(1);
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
cur_time = localtime ( &rawtime );
sensor.set_datetime(cur_time);
}
void loop() {
float error = PID(90)
myservo.watch(error)
if error < 1.0 {resistance = 1};
else if error < 3.0 {resistance = 2};
else if error < 7.0 {resistance = 3};
else if error < 15.0 {resistance = 4};
else {resistance = 5};
delay(100);
sensor.set_resistance(resistance);
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
cur_time = localtime ( &rawtime );
sensor.set_datetime(cur_time);
sensor.SerializeToString(&data);
}