Use the Analog pots to mix 2 colours ,red and green, print the analog values of the pot every 0.5 secs.

Dependencies:   mbed

main.cpp

Committer:
t00203959
Date:
2019-05-22
Revision:
0:c3c42383ed71

File content as of revision 0:c3c42383ed71:

#include "mbed.h"

AnalogIn mypotentiometer1 (p19); // reads potentiometer1 value
AnalogIn mypotentiometer2 (p20); // reads potentiometer2 value

PwmOut red(p24); // initilizes red led
PwmOut green(p25); // initilizes green led

float p1, p2; // creates float for both potentiometer values

Serial pc(USBTX, USBRX); // initilizes output to Tera Term

int main()
{
    while(1) {
        p1 = mypotentiometer1 * 100;  // converts signal to value between 0 and 1
        p2 = mypotentiometer2 * 100;  // converts signal to value between 0 and 1
                {
                    red = mypotentiometer1; // assigns red led to potentiometer1
                    green = mypotentiometer2;  // assigns green led to potentiometer2
                    
                }             
        wait(0.5);  // time in secs mbed checks potentiometer values     
        pc.printf("%f \n\r", mypotentiometer1.read()); // prints reading on Tera Term for potentiometer 1 value
        pc.printf("%f \n\r", mypotentiometer2.read()); // prints reading on Tera Term for potentiometer 2 value
    }
}