Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / utilities / manual_control / manualControlRobot / manualControlRobot.c @ 13

History | View | Annotate | Download (1.41 KB)

1
/*
2
Ryan Kellogg 
3
10/12/06
4
manualControlRobot - Receives commands from server and executes
5
*/
6

    
7
/* Includes */
8
#include <stdio.h>
9
#include <string.h>
10
 
11
#include <firefly+_lib.h>
12
#include "pindefs_ff.h"
13

    
14
#include <wireless.h>
15

    
16
#define FORWARD 0xF0
17
#define BACK 0xF1
18
#define RIGHT 0xF2
19
#define LEFT 0xF3
20
#define STOP 0xF4
21

    
22
void init_hardware(void);
23

    
24
/* Main */
25
int main(void){
26
  char buf[80];
27
  char src, dest;
28
  
29
  init_hardware();
30
  wl_init(3,1);
31

    
32
  orb_set_color(GREEN);
33

    
34
  while(1){
35
    if(wl_recv(buf, &src, &dest)){
36
      lcd_putchar('[');
37
      lcd_putchar(buf[0]);
38
      lcd_putchar(']');
39
      orb_set_color(RED);
40
    }else{
41
      printf(".");
42
      orb_set_color(GREEN);
43
    }
44
    
45
    switch(buf[0]){
46
      case FORWARD:
47
        motor1_set(0,255);
48
        motor2_set(0,255);
49
        break;
50
      case BACK:
51
        motor1_set(1,255);
52
        motor2_set(1,255);
53
        break;
54
      case LEFT:
55
        motor1_set(1,255);
56
        motor2_set(0,255);
57
        delay_ms(150);
58
        motors_off();
59
        break;
60
      case RIGHT:
61
        motor1_set(0,255);
62
        motor2_set(1,255);
63
        delay_ms(150);
64
        motors_off();
65
        break;
66
      case STOP:
67
        motors_off();
68
      }
69
      
70
      buf[0] = 0;
71
  }
72
  
73
  return 0;
74
}
75

    
76
void init_hardware(){
77
  motors_init();
78
  orb_init();
79
  led_init();
80
  analog_init();
81
  
82
  serial_init(BAUD9600);
83
  serial1_init(BAUD115200);2
84
  lcd_init();
85

    
86
  fdevopen(&serial1_putchar, &serial1_getchar);
87
}