-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoverC.cpp
72 lines (61 loc) · 1.28 KB
/
RoverC.cpp
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
#include "RoverC.h"
void RoverC_Init(void) //sda 0 scl 26
{
Wire.begin(0,26,100);
}
void Send_iic(uint8_t Register, uint8_t Speed)
{
Wire.beginTransmission(ROVER_ADDRESS);
Wire.write(Register);
Wire.write(Speed);
Wire.endTransmission();
}
void Move_forward(int8_t Speed)
{
Send_iic(0x00, Speed );
Send_iic(0x01, Speed );
Send_iic(0x02, Speed );
Send_iic(0x03, Speed );
}
void Move_back(int8_t Speed)
{
Send_iic(0x00, (-1) * Speed );
Send_iic(0x01, (-1) * Speed );
Send_iic(0x02, (-1) * Speed );
Send_iic(0x03, (-1) * Speed );
}
void Move_turnleft(int8_t Speed)
{
Send_iic(0x00, Speed );
Send_iic(0x01, (-1) * Speed );
Send_iic(0x02, Speed );
Send_iic(0x03, (-1) * Speed );
}
void Move_turnright(int8_t Speed)
{
Send_iic(0x00, (-1) * Speed );
Send_iic(0x01, Speed );
Send_iic(0x02, (-1) * Speed );
Send_iic(0x03, Speed );
}
void Move_left(int8_t Speed)
{
Send_iic(0x00, (-1) * Speed );
Send_iic(0x01, Speed );
Send_iic(0x02, Speed );
Send_iic(0x03, (-1) * Speed );
}
void Move_right(int8_t Speed)
{
Send_iic(0x00, Speed );
Send_iic(0x01, (-1) * Speed );
Send_iic(0x02, (-1) * Speed );
Send_iic(0x03, Speed );
}
void Move_stop(int8_t Speed)
{
Send_iic(0x00, 0 );
Send_iic(0x01, 0 );
Send_iic(0x02, 0 );
Send_iic(0x03, 0 );
}