Demonstrates the use of two pumps using Hbridge

Dependencies:   Motor mbed

Committer:
djrox316
Date:
Mon May 01 00:30:40 2017 +0000
Revision:
0:296f37bd5ce3
Drink

Who changed what in which revision?

UserRevisionLine numberNew contents of line
djrox316 0:296f37bd5ce3 1 // Demonstrates the use of two pumps using Hbridge, utilizes the forward and
djrox316 0:296f37bd5ce3 2 // reverse functionality to dispense one drink or the other. This code
djrox316 0:296f37bd5ce3 3 // starts one pump for 3 seconds then turns it off then starts the second
djrox316 0:296f37bd5ce3 4 // pump for 3 seconds and turns it off. Then both pumps remain off for 3 seconds
djrox316 0:296f37bd5ce3 5 // then the system repeats the process.
djrox316 0:296f37bd5ce3 6
djrox316 0:296f37bd5ce3 7 #include "mbed.h"
djrox316 0:296f37bd5ce3 8 #include "Motor.h"
djrox316 0:296f37bd5ce3 9 DigitalIn stby(p25);
djrox316 0:296f37bd5ce3 10 Motor pump(p26, p13, p14); // pwm, fwd, rev (H-bridge)
djrox316 0:296f37bd5ce3 11
djrox316 0:296f37bd5ce3 12
djrox316 0:296f37bd5ce3 13 int main() {
djrox316 0:296f37bd5ce3 14 stby.mode(PullUp);
djrox316 0:296f37bd5ce3 15 while(1){
djrox316 0:296f37bd5ce3 16 pump.speed(1); // Drink 1 dispenses
djrox316 0:296f37bd5ce3 17 wait(3);
djrox316 0:296f37bd5ce3 18 pump.speed(-1); // Drink 2 dispenses
djrox316 0:296f37bd5ce3 19 wait(3);
djrox316 0:296f37bd5ce3 20 pump.speed(0); // pumps are stopped
djrox316 0:296f37bd5ce3 21 wait(3);
djrox316 0:296f37bd5ce3 22 }
djrox316 0:296f37bd5ce3 23 }
djrox316 0:296f37bd5ce3 24