; A simple program to change motor directions depending on presses of the touch sensor. #define SRC_VAR 0 #define SRC_CON 2 #define SRC_SEN 13 #define DIR_FWD 2 #define DIR_REV 0 #define MOT_FLOAT 0 #define MOT_OFF 1 #define MOT_ON 2 #define GT 0 #define LT 1 #define EQ 2 #define NE 3 task 0 ; main task sent 0,1 ; sensor 0 is a switch senm 0,1,0 ; mode is boolean ; disp the value of the sensor on the LCD disp 0, SRC_VAR, 30 ; Start motor forward at power level 3 and start the motor dir DIR_FWD, 1 pwr 1, SRC_CON, 3 out MOT_ON, 1 ; loop that checks the touch sensor and changes the motor state loopy: wait SRC_CON, 100 ; kill some time ; if sensor 1's value equals 1, jump to beep else drop through chk SRC_CON, 1, EQ, SRC_SEN, 0, beep plays 3 ; simple beep out MOT_FLOAT, 1 wait SRC_CON, 50 dir DIR_FWD, 1 out MOT_ON, 1 jmp loopy beep: plays 1 ; play a scale ; Float the motor, wait and then reverse the direction out MOT_FLOAT, 1 wait SRC_CON, 50 dir DIR_REV, 1 out MOT_ON, 1 jmp loopy endt