Ryszard Piatek
/
LAB3_COLOURMIX
Changes the colour of the RGB Led using the potentiometers
Diff: main.cpp
- Revision:
- 0:1ee7ebd7d308
diff -r 000000000000 -r 1ee7ebd7d308 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 07 01:13:40 2019 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h"//includes mbed header + +AnalogIn pot1(p19);// Declares P19 as an analouge in called pot1 +AnalogIn pot2(p20);// Declares P20 as an analouge in called pot2 +PwmOut red(p25);// Declares P25 as a Pulse Width Modulation out called red +PwmOut blue(p23);// Declares P23 as a Pulse Width Modulation out called blue +Serial pc(USBTX, USBRX);// sets up serial connection to PC + +int main() +{ + while(1) { + red = !pot1;// makes the value of red equal to pot1 + blue = !pot2;// makes the value of blue equal to pot2 + red = !red;//makes red equal to not red + blue = !blue;//makes blue equal to not blue + pc.printf("Red = %f & Blue = %f\n\n\r",red.read(),blue.read());// prints values to Pc + wait(0.1); + } +} +