int led =13;//the led pin
char input;// to save the input
void setup () {
pinMode (led,OUTPUT);//tell that the 13 pin is an output
Serial.begin(9600);//for the connect with the board
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
Serial.begin(9600);
pinMode (led,OUTPUT);//tell that the 13 pin is an output
Serial.begin(9600);//for the connect with the board
};
void loop(){
char customKey = customKeypad;
if (customKey){
Serial.println(customKey);
if (Serial.available()) {
input = Serial.read();//read the input
if (input == 'a' || input == 'A') {lA();}//if the input is a or A go to function A
if (input == 'b' || input == 'B') {lB();}//same but with b letter
if (input == 'c' || input == 'C') {lC();}
if (input == 'd' || input == 'D') {lD();}
if (input == '1') {n1();}// the numbers
if (input == '2') {n2();}
if (input == '3') {n3();}
if (input == '4') {n4();}
if (input == '5') {n5();}
if (input == '6') {n6();}
if (input == '7') {n7();}
if (input == '8') {n8();}
if (input == '9') {n9();}
if (input == '0') {n0();}
if (input == '*') {space();}//the space
Serial.println (input);//print the latter saved in the input var
}
}
//functions for the letters and the numbers
void A () {dot();dash();shortspace();}//letter A in morse code!
void B () {dash();dot();dot();dot();shortspace();}//same for B
void C () {dash();dot();dash();dot();shortspace();}
void D () {dash();dot();dot();shortspace();}
void 1 () {dot();dash();dash();dash();dash();shortspace();}//number 1 in morse code
void 2 () {dot();dot();dash();dash();dash();shortspace();}
void 3 () {dot();dot();dot();dash();dash();shortspace();}
void 4 () {dot();dot();dot();dot();dash();shortspace();}
void 5 () {dot();dot();dot();dot();dot();shortspace();}
void 6 () {dash();dot();dot();dot();dot();shortspace();}
void 7 () {dash();dash();dot();dot();dot();shortspace();}
void 8 () {dash();dash();dash();dot();dot();shortspace();}
void 9 () {dash();dash();dash();dash();dot();shortspace();}
void 0 () {dash();dash();dash();dash();dash();shortspace();}
void space () {delay (1200);}//space between words
void dot () {digitalWrite(led,HIGH); delay (300); digitalWrite(led,LOW); delay (300);}//the dot this code make the led on for 300 than off for 300
void dash () {digitalWrite(led,HIGH); delay (900); digitalWrite(led,LOW); delay (300);}//the dash this code make the led on for 900 than off for 300
void shortspace () {delay(600);}//space between letters
}
}