Analog comms with xbee. Program for the Coordinator.

Dependencies:   C12832_lcd mbed xbeeLibDannelly

Fork of Xbee_Hello_World_B by Tristan Hughes

Revision:
2:9b7d98c295d9
Parent:
1:4ce1378831fe
--- a/main.cpp	Sun Feb 15 16:40:31 2015 +0000
+++ b/main.cpp	Sun Feb 15 17:10:17 2015 +0000
@@ -6,6 +6,11 @@
 DigitalOut rst1(p30);
 Serial pc(USBTX, USBRX); //Initalise PC serial comms
 C12832_LCD lcd; //Initialize LCD Screen
+PwmOut speaker(p26); //Speaker with PWM driver
+//RGB LED with 3 PWM outputs for dimmer control
+PwmOut r(p23); 
+PwmOut g(p24);
+PwmOut b(p25);
 
 int main()
 {
@@ -28,6 +33,14 @@
     lcd.cls();      
     lcd.locate(0,1);
     
+    //Setup speaker
+    speaker.period(1.0/800.0); // 800hz period
+    
+    //Setup RGB
+    r=1.0;
+    g=1.0;
+    b=1.0;
+    
     
     while(1) {
         
@@ -49,6 +62,12 @@
         float pot1 = atof(readData2);
         float pot2 = atof(readData1);
         
+        
+        //Change red value with pot1 
+        r = 1- pot1;
+        //Change blue value with pot2
+        b = 1- pot2; 
+        
         //Echo data 
         pc.printf("Pot1= %.2f Pot2= %.2f \n\r",pot1,pot2);
         lcd.printf("Pot1= %.2f Pot2= %.2f \n\r",pot1,pot2);