Ce programme correspond a la cellule d'arrivee du systeme "Laser Gate Timer" developpe par Tanguy KESSELY et Dorian VOYDIE. Il utilise une carte Nucleo F411, un shield BLE IDB05A1 et un PCB fait maison

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dorianvoydie
Date:
Thu Feb 04 16:09:48 2021 +0000
Parent:
1:417efc7560c8
Commit message:
Ce programme correspond a la cellule d'arrivee du systeme "Laser Gate Timer" developpe par Tanguy KESSELY et Dorian VOYDIE. Il utilise une carte Nucleo F411, un shield BLE IDB05A1 et un PCB fait maison

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 417efc7560c8 -r 06ec0e48f564 main.cpp
--- a/main.cpp	Tue Nov 17 17:19:59 2020 +0000
+++ b/main.cpp	Thu Feb 04 16:09:48 2021 +0000
@@ -1,58 +1,67 @@
-//Includes
-
 #include "mbed.h"
-
+///////////Init Device/////////////////
+Serial device(D8, D2);
+Serial pc(USBTX, USBRX);
+/////////////////////////////////////
 
 ///////////Init STM32 pins///////////
 DigitalOut myLed(LED1);
+DigitalOut compteur(A3);
+DigitalOut laser(A5);
+InterruptIn photodiode(A4);
 InterruptIn my_button(USER_BUTTON);  //User1
 /////////////////////////////////////
 
 
-
-
-///////////Init HC05/////////////////
-Serial HC05(D8, D2);
-//Bluetooth
-//Maitre (Arrivee) : ADDR = 98d3,b1,fd5c5d
-//Esclave (Départ) : ADDR = 0019,10,08FCB5
-/////////////////////////////////////
-
-
-
-
 /////////COMMUNICATION///////////////
-void HC05_transmit()
+void device_nodetect()
 {
-    HC05.putc('u');
+    compteur = 1;
+    wait(0.001);
+    compteur = 0;
+    for( int h = 0; h < 2; h++ ) {
+        device.putc(0xBB);
+        device.putc(0xBB);
+        device.putc(0xBB);
+        device.putc(0xBC);
+        device.putc(0xBC);
+        device.putc(0xBC);
+        device.putc(0xBD);
+        device.putc(0xBD);
+        device.putc(0xBD);
+    }
+    
 }
-/////////////////////////////////////
-
-
-
-
-/////////////GAMEMODES///////////////
-void solo()
+void device_detect()
 {
-
+    compteur = 1;
+    wait(0.001);
+    compteur = 0;
+    for( int h = 0; h < 10; h++ ) {
+        device.putc(0xCC);
+    }
 }
 /////////////////////////////////////
 
 
 int main(int, char**)
 {
-    HC05.baud(38400);
-    my_button.fall(&HC05_transmit);
-    
+    device.baud(2400);
+    my_button.fall(&device_nodetect);
+    photodiode.rise(&device_detect);
+    photodiode.fall(&device_nodetect);
+    laser = 1;
+
     while (1) {
-        //while bluetooth device is receiving data
-
+        //while RF device is receiving data
+        //RF Transmit Code
+        //Send 10101010 pattern when idle to keep receiver in sync and locked to transmitter
+        //When receiver loses the sync lock (Around 30MS with no data change seen) it starts sending out noise
+        device.putc(0xAA);
+        for( int h = 0; h < 10; h++ ) {
+            
+            device.putc('x');
+        }
+        wait(1);
     }
-}
-
-
-
-
-
-
-
+}
\ No newline at end of file