ECE 4180 Labs / Mbed 2 deprecated 4180_Lab1_RGB_XC

Dependencies:   mbed

Committer:
jeremycai3721
Date:
Sun Sep 25 20:19:50 2016 +0000
Revision:
0:3a5416fc52a1
CodeShare

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jeremycai3721 0:3a5416fc52a1 1 #include "mbed.h"
jeremycai3721 0:3a5416fc52a1 2
jeremycai3721 0:3a5416fc52a1 3 PwmOut GREEN(p22); // normal LED
jeremycai3721 0:3a5416fc52a1 4 PwmOut BLUE(p21); // normal LED
jeremycai3721 0:3a5416fc52a1 5
jeremycai3721 0:3a5416fc52a1 6 AnalogIn AinBLUE(p20);
jeremycai3721 0:3a5416fc52a1 7 AnalogIn AinGREEN(p19);
jeremycai3721 0:3a5416fc52a1 8
jeremycai3721 0:3a5416fc52a1 9
jeremycai3721 0:3a5416fc52a1 10 int main()
jeremycai3721 0:3a5416fc52a1 11 {
jeremycai3721 0:3a5416fc52a1 12 float dcBLUE; // 50% duty cycle
jeremycai3721 0:3a5416fc52a1 13 float dcGREEN;
jeremycai3721 0:3a5416fc52a1 14
jeremycai3721 0:3a5416fc52a1 15 GREEN.period(0.01f); // 0.01 second period
jeremycai3721 0:3a5416fc52a1 16 BLUE.period(0.01f); // 0.01 second period
jeremycai3721 0:3a5416fc52a1 17
jeremycai3721 0:3a5416fc52a1 18 while (1) {
jeremycai3721 0:3a5416fc52a1 19 dcBLUE = 0.5*AinBLUE;
jeremycai3721 0:3a5416fc52a1 20 dcGREEN = 0.5*AinGREEN;
jeremycai3721 0:3a5416fc52a1 21 BLUE.write(dcBLUE);
jeremycai3721 0:3a5416fc52a1 22 GREEN.write(dcGREEN);
jeremycai3721 0:3a5416fc52a1 23 wait(0.1);
jeremycai3721 0:3a5416fc52a1 24 }
jeremycai3721 0:3a5416fc52a1 25 return 0;
jeremycai3721 0:3a5416fc52a1 26 }