lab question 3

Dependencies:   mbed

Committer:
niallmoyvane
Date:
Tue May 21 12:00:33 2019 +0000
Revision:
0:52c0110393c4
lab question 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
niallmoyvane 0:52c0110393c4 1 #include "mbed.h"
niallmoyvane 0:52c0110393c4 2
niallmoyvane 0:52c0110393c4 3 PwmOut red(p23);
niallmoyvane 0:52c0110393c4 4 PwmOut green(p24);
niallmoyvane 0:52c0110393c4 5 AnalogIn pot1(p19);
niallmoyvane 0:52c0110393c4 6 AnalogIn pot2(p20);
niallmoyvane 0:52c0110393c4 7 Serial pc(USBTX,USBRX);
niallmoyvane 0:52c0110393c4 8
niallmoyvane 0:52c0110393c4 9 float a,b;
niallmoyvane 0:52c0110393c4 10
niallmoyvane 0:52c0110393c4 11 int main()
niallmoyvane 0:52c0110393c4 12 {
niallmoyvane 0:52c0110393c4 13 while(1)
niallmoyvane 0:52c0110393c4 14 {
niallmoyvane 0:52c0110393c4 15 a=pot1*100; //the value requires to be multiplied by 100
niallmoyvane 0:52c0110393c4 16 red=pot1;
niallmoyvane 0:52c0110393c4 17
niallmoyvane 0:52c0110393c4 18 b=pot2*100; //in order to get the percentage
niallmoyvane 0:52c0110393c4 19 green=pot2;
niallmoyvane 0:52c0110393c4 20
niallmoyvane 0:52c0110393c4 21 pc.printf("Pot 1 position is: %3f\n\r",a);
niallmoyvane 0:52c0110393c4 22 wait(2);
niallmoyvane 0:52c0110393c4 23
niallmoyvane 0:52c0110393c4 24 pc.printf("Pot 2 position is: %3f\n\r",b);
niallmoyvane 0:52c0110393c4 25 wait(2);
niallmoyvane 0:52c0110393c4 26 }
niallmoyvane 0:52c0110393c4 27 }
niallmoyvane 0:52c0110393c4 28