-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·75 lines (59 loc) · 1.83 KB
/
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
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
// ******************************************************************************************* //
//
// Filename : Main.c
// Title : RoboGolfer Main File
// Author : Fan Wing Sze
// Description : This file is the Main File of the RoboGolfer Project.
//
// ******************************************************************************************* //
///------------------------------------------------------------------------------------------------------///
///---------------------------- INCLUDE FILES ---------------------------------------------------------///
///------------------------------------------------------------------------------------------------------///
#include "Global.h"
///------------------------------------------------------------------------------------------------------///
///---------------------------- FUNCTIONS ---------------------------------------------------------///
///------------------------------------------------------------------------------------------------------///
void IO_init(void)
{
DDRA = 0b00000000;
DDRB = 0b10011111;
DDRC = 0b11111111;
DDRD = 0b11110010;
PORTA = 0b00000000;
PORTB = 0b00000000;
PORTC = 0b00000000;
PORTD = 0b00000001;
}
//Call this function for controlling the robot manually
void inherent_function(void)
{
ADC_update();
if(!SW_IN_2 && !SW_IN_1) //enter the line following mode when button S5 and S6 are pressed together
{
while(!SW_IN_2 || !SW_IN_1)
{
test_mode();
}
}
else if(!SW_IN_1) //enter the manual control mode when button S6 is pressed
{
while(!SW_IN_1);
test_mode();
}
}
int main(void)
{
IO_init();
Timer1_init();
ADC_init();
Motor_stop();
Servo_init();
LCD_init();
sei();
while(1)
{
inherent_function();
}
while(1);
return 0;
}