Changes the colour of the RGB Led using the potentiometers

Dependencies:   mbed

main.cpp

Committer:
t00203814
Date:
2019-08-07
Revision:
0:1ee7ebd7d308

File content as of revision 0:1ee7ebd7d308:

#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);
    }
}