First program with shield

Dependencies:   C12832

Committer:
deboerengamer
Date:
Mon Feb 10 09:42:11 2020 +0000
Revision:
7:adfd46d88d34
Parent:
6:f8cb706c480c
New Program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:f6a57b843f79 1 #include "mbed.h"
chris 3:2db94ee076ee 2 #include "C12832.h"
dreschpe 0:f6a57b843f79 3
chris 4:39c7c31b8fb0 4 // Using Arduino pin notation
chris 4:39c7c31b8fb0 5 C12832 lcd(D11, D13, D12, D7, D10);
dreschpe 1:1c6a9eaf55b5 6
dreschpe 0:f6a57b843f79 7 int main()
dreschpe 0:f6a57b843f79 8 {
deboerengamer 7:adfd46d88d34 9 AnalogIn pot1 (A0);
deboerengamer 7:adfd46d88d34 10 AnalogIn pot2 (A1);
deboerengamer 7:adfd46d88d34 11 PwmOut r (D5);
deboerengamer 7:adfd46d88d34 12 PwmOut g (D8);
deboerengamer 7:adfd46d88d34 13 PwmOut b (D9);
dreschpe 0:f6a57b843f79 14
dreschpe 0:f6a57b843f79 15 while(true) { // this is the third thread
deboerengamer 7:adfd46d88d34 16
deboerengamer 7:adfd46d88d34 17 r = 1.0 - ((pot1 < 1.0) ? 1.0 - pot1 : (pot1 > 2.0) ? pot1 - 2.0 : 0.0);
deboerengamer 7:adfd46d88d34 18 g = 1.0 - ((pot1 < 1.0) ? pot1 : (pot1 > 2.0) ? 0.0 : 2.0 - pot1);
deboerengamer 7:adfd46d88d34 19 b = 1.0 - ((pot1 < 1.0) ? 0.0 : (pot1 > 2.0) ? 3.0 - pot1 : pot1 - 1.0); ;
deboerengamer 7:adfd46d88d34 20 lcd.locate(0,3);
deboerengamer 7:adfd46d88d34 21 lcd.printf("Pot 2 = %.2f", (float)pot2);
deboerengamer 7:adfd46d88d34 22 wait(0.2);
dreschpe 0:f6a57b843f79 23 }
dreschpe 0:f6a57b843f79 24 }