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

Dependencies:   mbed

Committer:
afm76
Date:
Mon Mar 05 01:54:32 2018 +0000
Revision:
1:c07bb4813cc3
Parent:
0:409a7398165b
Child:
2:016bda11f251
Usando bot?es da placa Joystick Shield V2.4 Xinda.

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 1:c07bb4813cc3 20 pc.printf("Hello World!!!\n\r");
afm76 0:409a7398165b 21
afm76 0:409a7398165b 22 while(1) {
afm76 0:409a7398165b 23 if (botao_A == 0) { // Botão usuário pressionado
afm76 1:c07bb4813cc3 24 pc.printf("\n\rTecla A");
afm76 0:409a7398165b 25 }
afm76 0:409a7398165b 26 if (botao_B == 0) { // Botão externo pressionado
afm76 1:c07bb4813cc3 27 pc.printf("\n\rTecla B");
afm76 0:409a7398165b 28 }
afm76 0:409a7398165b 29 if (botao_C == 0) { // Botão usuário pressionado
afm76 1:c07bb4813cc3 30 pc.printf("\n\rTecla C");
afm76 0:409a7398165b 31 }
afm76 0:409a7398165b 32 if (botao_D == 0) { // Botão usuário pressionado
afm76 1:c07bb4813cc3 33 pc.printf("\n\rTecla D");
afm76 0:409a7398165b 34 }
afm76 0:409a7398165b 35 if (botao_E == 0) { // Botão usuário pressionado
afm76 1:c07bb4813cc3 36 pc.printf("\n\rTecla E");
afm76 0:409a7398165b 37 }
afm76 0:409a7398165b 38 if (botao_F == 0) { // Botão usuário pressionado
afm76 1:c07bb4813cc3 39 pc.printf("\n\rTecla F");
afm76 0:409a7398165b 40 }
afm76 0:409a7398165b 41
afm76 1:c07bb4813cc3 42 for (i = 10; i < 100; i+=10){}
afm76 0:409a7398165b 43 }
afm76 0:409a7398165b 44 }
afm76 0:409a7398165b 45