version2...

Dependencies:   mbed

Revision:
2:238093c1d98d
Parent:
1:4a28329e243f
--- a/main.cpp	Thu Apr 16 11:15:25 2015 +0000
+++ b/main.cpp	Thu Apr 23 09:14:44 2015 +0000
@@ -1,60 +1,50 @@
 #include "mbed.h"
-#include "iostream"
 #include "stdio.h"
 #include "stdlib.h"
 
 using namespace std;
 
-Serial xbee1(PA_2, PA_3);
-//DigitalOut rst1(p11);
+Serial xbee1(PA_9, PA_10); //was PA_2, PA_3
+DigitalOut rst1(PA_11);
 DigitalOut myled(LED1);
 DigitalIn mybutton(USER_BUTTON);
 
 int counter = 0;
 void sendsignal();
-void receivesignal(char bericht);
 
 int main()
 {
-    while(1) {
-        if(xbee1.readable()) {
-            int message = xbee1.getc(); //XBee read
-            receivesignal(message);
-        }
+    
+    while(1) {   
         if (mybutton == 0) { //if button pressed
             sendsignal();
         }
+        rst1 = 0;   //Set reset pin to 0
+        myled = 0;
+        wait_ms(1);
+        rst1 = 1;   //Set reset pin to 1
+        wait_ms(1);
+        wait(2);
     }
 }
 
 void sendsignal()
 {
     if(counter == 0) {
-        xbee1.putc(counter); //XBee write
+        xbee1.putc(10); //XBee write
+        myled = 1; // LED is ON
+        wait(1);
+        counter++;
     }
-    if (counter == 1) {
-        xbee1.putc(counter);
+    else if (counter == 1) { //this one doesn't work for some reason :/
+        xbee1.putc(5);
         counter = 0;
+        myled = 1; // LED is ON
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+        myled = 1; // LED is ON
+        wait(0.2);
+        myled = 0;
     }
 }
-
-void receivesignal(int  bericht)
-{
-    if (bericht == 0) {
-        //make button signal x
-        myled = 1; // LED is ON
-        wait(0.1); // 200 ms
-        myled = 0; // LED is OFF
-        wait(0.1); // 1 sec
-        myled = 1;
-        wait(0.1);
-        myled = 0;
-        wait(0.4);
-    }
-    if (bericht == 1) {
-        myled = 1; // LED is ON
-        wait(1.0); // 200 ms
-        myled = 0; // LED is OFF
-        wait(1.0); // 1 sec
-    }
-}
\ No newline at end of file