Projeto Mecatrônico
/
ProjetoMecatronico
testando
main_PM.cpp
- Committer:
- enricoan
- Date:
- 2020-05-25
- Revision:
- 16:70baa0057a76
- Parent:
- 12:976d42656c4c
- Child:
- 17:4d0b8ed791e0
File content as of revision 16:70baa0057a76:
#include "mbed.h" #include "TextLCD.h" #include "Keypad.h" //local para a declaração de pinos e variáveis float t_motor = 0.003; float t_teclado = 0.01; int horario[] = {12,6,3,9}; int antih[] = {3,6,12,9}; int parado[] = {0,0,0,0}; char tecla; int fdc_x //botões para movimentação eixo a eixo DigitalIn x_mais(PA_0); DigitalIn x_menos(PA_1); DigitalIn y_mais(PC_0); DigitalIn y_menos(PC_1); DigitalIn z_mais(PC_2); DigitalIn z_menos(PC_3); //pinos da placa usados na biblioteca do LCD TextLCD lcd(D4, D5, D6, D7, D8, D9); //pinos 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 BusOut eixox(PA_15,PA_14,PA_13,PA_12); //eixo y BusOut eixoy(PA_11,PA_10,PB_2,PB_1); //eixo z BusOut eixoz(PC_9,PC_8,PB_8,PC_6); int main() { lcd.printf("Bem-vindo ao Pipemax"); lcd.locate(0,1); lcd.printf("o seu sistema"); lcd.locate(0,2); lcd.printf("automatizado"); lcd.locate(0,3); lcd.printf("de pipetagem"); 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 (tecla == '1'){ lcd.cls(); lcd.printf("A-Novo programa"); lcd.locate(0,1); lcd.printf("B-Carregar programa"); } if (x_mais == 0){for(int i = 0; i < 4; i++){eixox = horario[i];wait(t_motor);}} if (x_menos == 0){for(int i = 0; i < 4; i++){eixox = antih[i];wait(t_motor);}} if (y_mais == 0){for(int i = 0; i < 4; i++){eixoy = horario[i];wait(t_motor);}} if (y_menos == 0){for(int i = 0; i < 4; i++){eixoy = antih[i];wait(t_motor);}} if (z_mais == 0){for(int i = 0; i < 4; i++){eixoz = horario[i];wait(t_motor);}} if (z_menos == 0){for(int i = 0; i < 4; i++){eixoz = antih[i];wait(t_motor);}} if (x_mais || x_menos || y_mais || y_menos || z_mais || z_menos != 0){ for(int i = 0; i < 4; i++){eixox = parado[i];} for(int i = 0; i < 4; i++){eixoy = parado[i];} for(int i = 0; i < 4; i++){eixoz = parado[i];} } } }