dgfn

Dependencies:   mbed tsi_sensor

Files at this revision

API Documentation at this revision

Comitter:
benbrou06
Date:
Sat Dec 14 09:09:30 2019 +0000
Commit message:
yuez

Changed in this revision

lib.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
tsi_sensor.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib.h	Sat Dec 14 09:09:30 2019 +0000
@@ -0,0 +1,16 @@
+/* This defines will be replaced by PinNames soon */
+#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+#define ELEC0 9
+#define ELEC1 10
+#elif defined (TARGET_KL05Z)
+#define ELEC0 9
+#define ELEC1 8
+#else
+#error TARGET NOT DEFINED
+#endif
+
+TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
+float lire_slider()
+{
+    return (1-tsi.readPercentage());
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 14 09:09:30 2019 +0000
@@ -0,0 +1,61 @@
+//#define Test_Capteur
+#ifdef Test_Capteur
+
+#include <stdio.h>
+#include "mbed.h"
+
+
+//Entrées analogiques des capteurs
+AnalogIn Captd1(PTB1); //capteur droite 1
+AnalogIn Captd2(PTB2); //capteur droite 2
+AnalogIn Captg1(PTC2); //capteur gauche 1
+AnalogIn Captg2(PTB3); //capteur gauche 2
+
+
+PwmOut Motg(PTC8); //Déclaration PWM des moteurs
+PwmOut Motd(PTA13);
+
+
+
+int main()
+{
+    float CD1,CG1,CD2,CG2;
+    Motg.period_us(100);
+    Motd.period_us(100); 
+    float Vmg=100,Vmd=100; //Les 2 moteurs
+    Motg.pulsewidth_us(Vmg); //Vitesses des 2 moteurs
+    Motd.pulsewidth_us(Vmd);
+    printf("Debut pgrm\n\r");
+
+    while(1) {
+        CD1 = Captd1;
+        CD2 = Captd2;
+        CG1 = Captg1;
+        CG2 = Captg2;
+        printf("  CD1 = %.3f ",CD1);
+        printf("  CD2 = %.3f",CD2);
+        printf("  CG1 = %.3f",CG1);
+        printf("  CG2 = %.3f\n\r",CG2);
+        
+        
+   /*     
+        
+        if (Captg1 < 0.5) {
+            printf("Tourne a gauche\n\r");
+        }
+
+        else if (Captd1 < 0.5) {
+            printf("Tourne a droite\n\r");
+        }
+
+        else if (Captg2 < 0.5) {
+            printf("Tourne a gauche 90 deg\n\r");
+        }
+
+        else if (Captd2 < 0.5) {
+            printf("Tourne a droite 90 deg\n\r");
+        }*/
+
+    }
+}
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 14 09:09:30 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsi_sensor.lib	Sat Dec 14 09:09:30 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Kojto/code/tsi_sensor/#976904559b5c