Projeto Mecatrônico
/
ProjetoMecatronico
testando
Diff: main_PM.cpp
- Revision:
- 13:257302e01c7c
- Parent:
- 10:4f49e9859535
- Child:
- 14:69d8f50c2336
--- a/main_PM.cpp Sun May 24 21:11:08 2020 +0000 +++ b/main_PM.cpp Mon May 25 16:03:40 2020 +0000 @@ -3,8 +3,8 @@ #include "Keypad.h" //local para a declaração de pinos e variáveis -float t_motor = 0.008; -float t_teclado = 0.01; +float t_motor = 0.005; +float t_teclado = 0.1; //botões para movimentação eixo a eixo DigitalIn x_mais(PA_0); DigitalIn x_menos(PA_1); @@ -16,6 +16,9 @@ //pinos da placa usados na biblioteca do LCD TextLCD lcd(D4, D5, D6, D7, D8, D9); +//pinos da placa usados na biblioteca do teclado +Keypad teclado(PA_6, PA_7, PB_6, PC_7, PB_7, PC_13, PC_14, PC_15); + //pinos de saída para os motores //eixo x DigitalOut a1(PA_15); @@ -34,14 +37,26 @@ DigitalOut d3(PC_6); int main() { -lcd.printf(" Bem-vindo "); +lcd.printf("Pipemax"); lcd.locate(0,1); -lcd.printf(" ao Pipemax "); +lcd.printf("o seu sistema"); lcd.locate(0,2); -lcd.printf("o seu sistema automatizado"); +lcd.printf("automatizado"); lcd.locate(0,3); -lcd.printf(" de pipetagem"); +lcd.printf("de pipetagem"); +char tecla; + while(1) { + int solta = 1; + tecla = teclado.ReadKey(); //read the current key pressed + if(tecla == '\0') solta = 1; //set the flag when all keys are released + + if((tecla != '\0') && (solta == 1)) { //if a key is pressed AND previous key was released + printf("%c\n", tecla); + solta = 0; //clear the flag to indicate that key is still pressed + wait(0.1); + } + if (x_mais == 0){ a1 = 1;b1 = 1;wait(t_motor); a1 = 0;c1 = 1;wait(t_motor);