Project

General

Profile

Revision 048ed7e1

ID048ed7e1dbde71a25f5c2a6633de8ea027828dd5

Added by Thomas Mullins about 12 years ago

Added analog.c for line following and linear pot

Most of the line following was copy-pasted from Colony 3. Still unsure
about prescaler, which used to be 2 for some reason but is now 64.

View differences:

forklift/code/forklift.c
12 12
 */
13 13
 
14 14
#include "twi.h"
15
#include "analog.h"
15 16

  
16 17
#define TRACKING_ID 0x41
17 18
#define SERIAL_NUMBER 0x12
......
21 22
#define FORKLIFT_SERIAL_NUMBER   1
22 23
#define FORKLIFT_HEIGHT          2
23 24
#define FORKLIFT_HEIGHT_SETPOINT 3 // only one that's r/w
24
#define FORKLIFT_FORCE           4
25
#define FORKLIFT_LINEPOS         4
25 26

  
26 27
#define FORKLIFT_DATA_LEN        5
27 28

  
......
58 59
  twi_setAddress(TRACKING_ID);
59 60
  twi_attachSlaveRxEvent(slave_rx);
60 61
  twi_attachSlaveTxEvent(slave_tx);
62
  analog_init();
61 63
  while (1)
62 64
  {
63 65
    // do motor stuff
66
    internal_data[FORKLIFT_LINEPOS] = line_read_pos();
67
    internal_data[FORKLIFT_HEIGHT] = analog_read(ADC_HEIGHT);
64 68
  }
65 69
  return 0;
66 70
}

Also available in: Unified diff