Extra Program

Dependencies:   C12832 MMA7660

main.cpp

Committer:
deboerengamer
Date:
2020-02-10
Revision:
7:adfd46d88d34
Parent:
6:f8cb706c480c
Child:
8:f66441d6b175

File content as of revision 7:adfd46d88d34:

#include "mbed.h"
#include "C12832.h"

// Using Arduino pin notation
C12832 lcd(D11, D13, D12, D7, D10);

int main()
{
    AnalogIn pot1 (A0);
    AnalogIn pot2 (A1);
    PwmOut r (D5);
    PwmOut g (D8);
    PwmOut b (D9);

    while(true) {   // this is the third thread
        
            r = 1.0 - ((pot1 < 1.0) ? 1.0 - pot1 : (pot1 > 2.0) ? pot1 - 2.0 : 0.0);
            g = 1.0 - ((pot1 < 1.0) ? pot1 : (pot1 > 2.0) ? 0.0 : 2.0 - pot1);
            b = 1.0 - ((pot1 < 1.0) ? 0.0 : (pot1 > 2.0) ? 3.0 - pot1 : pot1 - 1.0);  ;
            lcd.locate(0,3);
            lcd.printf("Pot 2 = %.2f", (float)pot2);
        wait(0.2);
    }
}