#include const byte nR=4; const byte nC= 4; char km[nR][nC]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; byte rp[nR] = {9,8,7,6}; byte cp[nC]= {5,4,3,2}; Keypad myKeypad= Keypad(makeKeymap(km), rp, cp, nR, nC); int seleccion; int cantidad = 0; float pos ; int vuelta_completa = 33; int estados [9]; int tecla; char kp; int timer; int velocidad_sp = 1000; // SP VELOCIDAD. // 4 - 7 //8,9-11,12 void setup() { // put your setup code here, to run once: pinMode(11, OUTPUT); //ENABLE pinMode(13, OUTPUT); // DIR pinMode(10, OUTPUT); // PULSE Serial.begin(9600); } void loop() { teclado(); if (kp == 'B'){ timer = timer + 1; Serial.print(timer); } if (kp == 'C'){ speedDrive(velocidad_sp, 1, 10, 1000, 50); cantidad = 0; Serial.println("UP"); } if (kp == 'D'){ speedDrive(velocidad_sp, 0, 10, 500, 100); cantidad = 0; Serial.println("DOWN"); } if (timer == 1 ) { speedDrive(velocidad_sp, 1, 10, 500, 100); cantidad = 0; } if ( timer >= 2 ){ timer = 0; } } void speedDrive(int sp, int dir, int pin_OUT, int pasos, int vecez){ if ( dir == 1 ){ digitalWrite(13, HIGH); } else { digitalWrite(13,LOW); } if (cantidad < vecez ){ for (int x; x <= pasos ; x++){ digitalWrite (pin_OUT, HIGH); delayMicroseconds(sp); digitalWrite (pin_OUT, LOW); } cantidad = cantidad + 1; } } void teclado(){ kp = myKeypad.getKey(); Serial.print(kp); }