leitura de botões na joystick shield v2.4 Xinda

Dependencies:   mbed

Committer:
afm76
Date:
Mon Mar 05 00:14:41 2018 +0000
Revision:
0:409a7398165b
Child:
1:c07bb4813cc3
Leitura de bot?es na Joystick shield V2.4 Xinda (not completed)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
afm76 0:409a7398165b 1
afm76 0:409a7398165b 2
afm76 0:409a7398165b 3 #include "mbed.h"
afm76 0:409a7398165b 4
afm76 0:409a7398165b 5 DigitalIn botao_A(D2);
afm76 0:409a7398165b 6 DigitalIn botao_B(D3);
afm76 0:409a7398165b 7 DigitalIn botao_C(D4);
afm76 0:409a7398165b 8 DigitalIn botao_D(D5);
afm76 0:409a7398165b 9 DigitalIn botao_E(D6);
afm76 0:409a7398165b 10 DigitalIn botao_F(D7);
afm76 0:409a7398165b 11
afm76 0:409a7398165b 12 DigitalOut myled(LED1);
afm76 0:409a7398165b 13
afm76 0:409a7398165b 14 Serial pc(USBTX, USBRX);
afm76 0:409a7398165b 15
afm76 0:409a7398165b 16 int main() {
afm76 0:409a7398165b 17 int i;
afm76 0:409a7398165b 18 pc.baud(9600);
afm76 0:409a7398165b 19
afm76 0:409a7398165b 20 pc.printf("Hello World!!!\n");
afm76 0:409a7398165b 21
afm76 0:409a7398165b 22 while(1) {
afm76 0:409a7398165b 23 if (botao_A == 0) { // Botão usuário pressionado
afm76 0:409a7398165b 24 pc.printf("\nTecla A");
afm76 0:409a7398165b 25 }
afm76 0:409a7398165b 26 if (botao_B == 0) { // Botão externo pressionado
afm76 0:409a7398165b 27 pc.printf("\nTecla B");
afm76 0:409a7398165b 28 }
afm76 0:409a7398165b 29 if (botao_C == 0) { // Botão usuário pressionado
afm76 0:409a7398165b 30 pc.printf("\nTecla C");
afm76 0:409a7398165b 31 }
afm76 0:409a7398165b 32 if (botao_D == 0) { // Botão usuário pressionado
afm76 0:409a7398165b 33 pc.printf("\nTecla D");
afm76 0:409a7398165b 34 }
afm76 0:409a7398165b 35 if (botao_E == 0) { // Botão usuário pressionado
afm76 0:409a7398165b 36 pc.printf("\nTecla E");
afm76 0:409a7398165b 37 }
afm76 0:409a7398165b 38 if (botao_F == 0) { // Botão usuário pressionado
afm76 0:409a7398165b 39 pc.printf("\nTecla F");
afm76 0:409a7398165b 40 }
afm76 0:409a7398165b 41
afm76 0:409a7398165b 42 for (i = 1; i < 1000; i+=1){}
afm76 0:409a7398165b 43 }
afm76 0:409a7398165b 44 }
afm76 0:409a7398165b 45