Este programa se destina a leitura via entradas analógicas dos pots do joystick MH, mais o botão via entrada digital PC_13. Usa o TeraTerm para visualizar as leituras.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
afm76
Date:
Wed Apr 07 18:23:13 2021 +0000
Parent:
3:3bcd9a1457fa
Commit message:
Joystick MH (VRX,VRY) to NUCLEO-F103RB (A0, A1), and SW to (PC_13)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Apr 07 18:03:48 2021 +0000
+++ b/main.cpp	Wed Apr 07 18:23:13 2021 +0000
@@ -30,7 +30,7 @@
 
 pc.printf("\t Hello World!!! - Здравствуйте Мир!!! - 大家好!!!\n\r");
 pc.printf("\n\rWelcome to the world of ADC (A0 and A1) conected to the MH Joystick \n\r- Digital In (PC_13) to Joystick SWitch included\n\r");
-pc.printf("\n\r\t\t\t\t!!!ATENTION!!! \n\r=> Joystick +5V pin MUST be connected to NUCLEO-F103RB 3V3 pin to avoid damaging NUCLEOs ADC!!!\n\r");
+pc.printf("\n\r\t\t\t\t!!!ATTENTION!!! \n\r=> Joystick +5V pin MUST be connected to NUCLEO-F103RB 3V3 pin to avoid damaging NUCLEOs ADC!!!\n\r");
 pc.printf("\n\r%s\t\t\t\t%s\t\t\t\t%s\n\r","Eixo X", "Eixo Y", "Tecla SW");
 
   while(1) {
@@ -39,8 +39,8 @@
 //    pc.printf("VRX = %f \t", VRX.read());
 //    pc.printf("VRY = %f \t", VRY.read());
 
-    xv = VRX.read()*3.300;          //lê valor da entrada analógica de 0,0 a 1,0 = full ADC conversion range e converte para faixa de 0,0 a 3,3V da alimentação
-    yv = VRY.read()*3.300;
+    xv = VRX.read()*3.300;          //lê valor da entrada analógica de 0,0 a 1,0 = full ADC conversion range 
+    yv = VRY.read()*3.300;          //e converte para faixa de 0,0 a 3,3V da alimentação
     
     x = VRX.read()*255;             //Converte uma leitura do ADC em float para formato int e armazena na variável x
     y = VRY.read()*255;             //Converte uma leitura do ADC em float para formato int e armazena na variável y
@@ -48,12 +48,15 @@
     pc.printf("VRX = %1.3fV (%03dd - 0x%02Xh)\t", xv, x, x);
     pc.printf("VRY = %1.3fV (%03dd - 0x%02Xh)\t", yv, y, y);
     
-    if (SW == 0) { // Botão usuário pressionado
+    if (SW == 0) {                  // Botão usuário pressionado
+      myled = 1;
+      wait(0.1);
+      myled = 0;
       i++;       }
       
     pc.printf("SW = %d\r",i);
  
-    wait(0.2);
+    wait(0.1);
 
  }
 }