Slams doors

Dependencies:   Motor RemoteIR TextLCD mbed

Committer:
mversteeg3
Date:
Fri Oct 12 17:49:16 2012 +0000
Revision:
0:15e49f97cb3d
Door slammer;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mversteeg3 0:15e49f97cb3d 1 #include "globlvar.h"
mversteeg3 0:15e49f97cb3d 2
mversteeg3 0:15e49f97cb3d 3 //Put all variables that must be accessible to all functions here.
mversteeg3 0:15e49f97cb3d 4
mversteeg3 0:15e49f97cb3d 5 #ifndef DEFINE_H
mversteeg3 0:15e49f97cb3d 6 #define DEFINE_H
mversteeg3 0:15e49f97cb3d 7
mversteeg3 0:15e49f97cb3d 8 #define PRINT(message) pc.printf( (message) );
mversteeg3 0:15e49f97cb3d 9
mversteeg3 0:15e49f97cb3d 10 #define PRINTLN(message) pc.printf( (message) );\
mversteeg3 0:15e49f97cb3d 11 pc.printf("\n\r");
mversteeg3 0:15e49f97cb3d 12
mversteeg3 0:15e49f97cb3d 13 #define LED(i) leds[i]
mversteeg3 0:15e49f97cb3d 14
mversteeg3 0:15e49f97cb3d 15 #define LED_0 1
mversteeg3 0:15e49f97cb3d 16 #define LED_1 2
mversteeg3 0:15e49f97cb3d 17 #define LED_2 4
mversteeg3 0:15e49f97cb3d 18 #define LED_3 8
mversteeg3 0:15e49f97cb3d 19
mversteeg3 0:15e49f97cb3d 20 #define CODE_ON
mversteeg3 0:15e49f97cb3d 21 #define FORWARD 1
mversteeg3 0:15e49f97cb3d 22 #define BACKWARD -1
mversteeg3 0:15e49f97cb3d 23
mversteeg3 0:15e49f97cb3d 24
mversteeg3 0:15e49f97cb3d 25 //OPTIONS
mversteeg3 0:15e49f97cb3d 26
mversteeg3 0:15e49f97cb3d 27 //Which side of the arm is the door
mversteeg3 0:15e49f97cb3d 28 #define DIRECTION BACKWARD
mversteeg3 0:15e49f97cb3d 29 //Minimum force to start pushing
mversteeg3 0:15e49f97cb3d 30 #define FORCE_MIN .05
mversteeg3 0:15e49f97cb3d 31 //Default value of the force threshold
mversteeg3 0:15e49f97cb3d 32 #define DEFAULT_FORCE .4
mversteeg3 0:15e49f97cb3d 33 //Default value for the speed
mversteeg3 0:15e49f97cb3d 34 #define DEFAULT_SPEED 1
mversteeg3 0:15e49f97cb3d 35 //Speed of the arm when not in contact with door
mversteeg3 0:15e49f97cb3d 36 #define COAST_SPEED .3
mversteeg3 0:15e49f97cb3d 37 //Speed of the arm when returning to wall
mversteeg3 0:15e49f97cb3d 38 #define REVERSE_SPEED -0.4
mversteeg3 0:15e49f97cb3d 39 //Force threshold for contact with wall
mversteeg3 0:15e49f97cb3d 40 #define WALL_THRESH .05
mversteeg3 0:15e49f97cb3d 41 //How long to push after contacting door
mversteeg3 0:15e49f97cb3d 42 #define PUSH_TIME .5
mversteeg3 0:15e49f97cb3d 43 //How much the speed changes with each button press
mversteeg3 0:15e49f97cb3d 44 #define SPEED_INC 0.05f
mversteeg3 0:15e49f97cb3d 45 //How much the force changes with each button press
mversteeg3 0:15e49f97cb3d 46 #define FORCE_INC 0.1f
mversteeg3 0:15e49f97cb3d 47
mversteeg3 0:15e49f97cb3d 48
mversteeg3 0:15e49f97cb3d 49
mversteeg3 0:15e49f97cb3d 50 #define SPEED_MIN COAST_SPEED
mversteeg3 0:15e49f97cb3d 51
mversteeg3 0:15e49f97cb3d 52 //BUTTON DEFINITIONS
mversteeg3 0:15e49f97cb3d 53 #define NONE -1
mversteeg3 0:15e49f97cb3d 54 #define SPD_DN 2
mversteeg3 0:15e49f97cb3d 55 #define SPD_UP 3
mversteeg3 0:15e49f97cb3d 56 #define FRC_UP 0
mversteeg3 0:15e49f97cb3d 57 #define FRC_DN 1
mversteeg3 0:15e49f97cb3d 58 #define RUN 14
mversteeg3 0:15e49f97cb3d 59 #define RST 69
mversteeg3 0:15e49f97cb3d 60
mversteeg3 0:15e49f97cb3d 61
mversteeg3 0:15e49f97cb3d 62
mversteeg3 0:15e49f97cb3d 63 #define SET_LEDS(mask, state) LED(0) = ((mask)&1!=0); \
mversteeg3 0:15e49f97cb3d 64 LED(1) = ((mask)&2!=0); \
mversteeg3 0:15e49f97cb3d 65 LED(2) = ((mask)&4!=0); \
mversteeg3 0:15e49f97cb3d 66 LED(0) = ((mask)&8!=0);
mversteeg3 0:15e49f97cb3d 67 #define ON 1
mversteeg3 0:15e49f97cb3d 68 #define OFF 0
mversteeg3 0:15e49f97cb3d 69
mversteeg3 0:15e49f97cb3d 70
mversteeg3 0:15e49f97cb3d 71 #endif