Final code for paint dispensing Machine

Dependencies:   mbed C12832

Committer:
vmg
Date:
Fri Jul 31 16:08:20 2020 +0000
Revision:
0:f58752ef18dd
Final code for Paint Dispensing machine Project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vmg 0:f58752ef18dd 1 // Pot1 controls the paint pump which controls the panit flow rate
vmg 0:f58752ef18dd 2 // Pot2 controls the speed of stepper motor of the axis
vmg 0:f58752ef18dd 3
vmg 0:f58752ef18dd 4
vmg 0:f58752ef18dd 5 #include "C12832.h"
vmg 0:f58752ef18dd 6 #include "mbed.h"
vmg 0:f58752ef18dd 7 C12832 lcd(p5,p7,p6,p8,p11);
vmg 0:f58752ef18dd 8 PwmOut led1(LED1);
vmg 0:f58752ef18dd 9 AnalogIn pot1(p19);
vmg 0:f58752ef18dd 10 PwmOut led4(LED4);
vmg 0:f58752ef18dd 11 AnalogIn pot2(p20);
vmg 0:f58752ef18dd 12 BusIn joy(p16,p13);
vmg 0:f58752ef18dd 13 DigitalIn fire(p14);
vmg 0:f58752ef18dd 14
vmg 0:f58752ef18dd 15 BusOut leds(LED2,LED3);
vmg 0:f58752ef18dd 16
vmg 0:f58752ef18dd 17 int main()
vmg 0:f58752ef18dd 18 {
vmg 0:f58752ef18dd 19 while(1)
vmg 0:f58752ef18dd 20 {
vmg 0:f58752ef18dd 21 if (fire) {
vmg 0:f58752ef18dd 22 leds=0xf;
vmg 0:f58752ef18dd 23 } else {
vmg 0:f58752ef18dd 24 leds=joy;
vmg 0:f58752ef18dd 25 }
vmg 0:f58752ef18dd 26
vmg 0:f58752ef18dd 27 lcd.locate(0,0); //keeps the output to lcd display in the same position each print
vmg 0:f58752ef18dd 28 lcd.printf("Pot 1 Paint flow rate %.2f",pot1.read()); //shows setting for pot1 - paint flow rate and sends message to lcd screen
vmg 0:f58752ef18dd 29 lcd.printf(" Pot 2 Axis Speed %.2f",pot2.read()); //shows setting for pot2 - axis speed - and sends message to lcd screen
vmg 0:f58752ef18dd 30
vmg 0:f58752ef18dd 31 led1 = pot1; //led1 is the output and controlled by pot1 and represents the Paint flow rate
vmg 0:f58752ef18dd 32 led4 = pot2; //led2 is the output controlled by pot2 and represents the axis speed
vmg 0:f58752ef18dd 33 wait(0.01); // the instruction to wait 0.01 of a second
vmg 0:f58752ef18dd 34
vmg 0:f58752ef18dd 35 }
vmg 0:f58752ef18dd 36 }
vmg 0:f58752ef18dd 37
vmg 0:f58752ef18dd 38