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 "mbed.h"
mversteeg3 0:15e49f97cb3d 2 #include "ReceiverIR.h"
mversteeg3 0:15e49f97cb3d 3 #include "Motor.h"
mversteeg3 0:15e49f97cb3d 4 #include "TextLCD.h"
mversteeg3 0:15e49f97cb3d 5
mversteeg3 0:15e49f97cb3d 6 #ifndef GLOBLVAR_H
mversteeg3 0:15e49f97cb3d 7 #define GLOBLVAR_H
mversteeg3 0:15e49f97cb3d 8
mversteeg3 0:15e49f97cb3d 9 //The IR receiver
mversteeg3 0:15e49f97cb3d 10 ReceiverIR ir_rx(p15);
mversteeg3 0:15e49f97cb3d 11 //The output serial port
mversteeg3 0:15e49f97cb3d 12 Serial pc(USBTX, USBRX);
mversteeg3 0:15e49f97cb3d 13 DigitalOut leds[] = {(LED1), (LED2),(LED3), (LED4)};
mversteeg3 0:15e49f97cb3d 14 //The force sensors
mversteeg3 0:15e49f97cb3d 15 AnalogIn doorForce(p16);
mversteeg3 0:15e49f97cb3d 16 AnalogIn wallForce(p20);
mversteeg3 0:15e49f97cb3d 17 //The motor
mversteeg3 0:15e49f97cb3d 18 Motor myMotor(p23,p6,p5);
mversteeg3 0:15e49f97cb3d 19 //The LCD
mversteeg3 0:15e49f97cb3d 20 TextLCD lcd(p24, p25, p26, p27, p28, p29, TextLCD::LCD20x4); // rs, e, d4-d7
mversteeg3 0:15e49f97cb3d 21
mversteeg3 0:15e49f97cb3d 22 bool newState=false;
mversteeg3 0:15e49f97cb3d 23 bool held;
mversteeg3 0:15e49f97cb3d 24 bool signal;
mversteeg3 0:15e49f97cb3d 25 float force;
mversteeg3 0:15e49f97cb3d 26 float wall;
mversteeg3 0:15e49f97cb3d 27 float speed;
mversteeg3 0:15e49f97cb3d 28 int speedPercent;
mversteeg3 0:15e49f97cb3d 29
mversteeg3 0:15e49f97cb3d 30 RemoteIR::Format format;
mversteeg3 0:15e49f97cb3d 31 float pushSpeed;
mversteeg3 0:15e49f97cb3d 32 float forceThresh;
mversteeg3 0:15e49f97cb3d 33
mversteeg3 0:15e49f97cb3d 34 //The states
mversteeg3 0:15e49f97cb3d 35 enum RunState
mversteeg3 0:15e49f97cb3d 36 {
mversteeg3 0:15e49f97cb3d 37 BOOT = 0,
mversteeg3 0:15e49f97cb3d 38 LISTEN,
mversteeg3 0:15e49f97cb3d 39 CLOSE_DOOR,
mversteeg3 0:15e49f97cb3d 40 CHECK_IR,
mversteeg3 0:15e49f97cb3d 41 CHECK_FORCE,
mversteeg3 0:15e49f97cb3d 42 CHECK_WALL,
mversteeg3 0:15e49f97cb3d 43 RUN_MOTOR,
mversteeg3 0:15e49f97cb3d 44 RESET,
mversteeg3 0:15e49f97cb3d 45 };
mversteeg3 0:15e49f97cb3d 46
mversteeg3 0:15e49f97cb3d 47
mversteeg3 0:15e49f97cb3d 48 RunState state = BOOT;
mversteeg3 0:15e49f97cb3d 49
mversteeg3 0:15e49f97cb3d 50 #endif