Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by birkan ( 7 years ago )
/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
byte rota[10];
byte i=0;
byte t=10;
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
//Serial.println("i= "+i);
switch (customKey) // sayaca göre switch kodunu çalıştır
{
case '0': // sayaca 0 ise
if (i>9) {
Serial.println("Maksimum hareket sayısına erişildi. Programı çalıştırın.");
break;
}
rota[i]=0;
Serial.print(i);
Serial.println(". adım ileri"); // ekrana cümleyi yaz
i=i+1;
customKey="";
break;
case '1': // sayaca 1 ise
if (i>9) {
Serial.println("Maksimum hareket sayısına erişildi. Programı çalıştırın.");
break;
}
rota[i]=1;
Serial.print(i);
Serial.println(" adım geri"); // ekrana cümleyi yaz
i=i+1;
customKey="";
break;
case '2': // sayaca 2 ise
if (i>9) {
Serial.println("Maksimum hareket sayısına erişildi. Programı çalıştırın.");
break;
}
rota[i]=2;
Serial.print(i);
Serial.println(" adım sag"); // ekrana cümleyi yaz
i=i+1;
customKey="";
break;
case '3': // sayaca 3 ise
if (i>9) {
Serial.println("Maksimum hareket sayısına erişildi. Programı çalıştırın.");
break;
}
rota[i]=3;
Serial.print(i);
Serial.println(" adım sol"); // ekrana cümleyi yaz
i=i+1;
customKey="";
break;
case '4': // sayaca 4 ise
if (i>=9) {
Serial.println("Başla"); // ekrana cümleyi yaz
for(int k=0; k<10; k++) {
if (rota[k]==0) {Serial.println("ileri");}
else if (rota[k]==1) {Serial.println("geri");}
else if (rota[k]==2) {Serial.println("sag");}
else if (rota[k]==3) {Serial.println("sol");}
}
}
customKey="";
break;
case '5': // sayaca 5 ise
for(int j=0; j<10; j++) {
rota[j]=0;
}
Serial.println("Sıfırlandı"); // ekrana cümleyi yaz
customKey="";
i=0;
break;
}
}
Revise this Paste