Keypad with Multi-TASKS

Hi, i am new to ARDUINO and i bought Arduino Mega 2650, The short story of what I am trying to do is making TASKS with keypad as the following sequence :

if i Press >> "1" , "2" , "#" >> first Led ON, if i Press >> "1" , "3" , "#" >> second Led ON, if i Press >> "1" , "4" , "#" >> Third Led ON, and so on.

Can any one help me !!!

Do you plan to press all 3 keys at the same time, or one after the other. These options will need different approaches to the coding.

I will assume you intend to press the keys one after the other.

You need to have some way to know when a key press sequence starts and ends. Pressing the # key might signify the end (and hence the start of a new sequence) but what happens if someone only presses one or two keys and then goes away. A long gap might be another signal for an end/start of a sequence.

Once your code knows when a sequence is starting it needs to record the keys that are pressed until there is a # key or a timeout. The simplest way would probably be to save them into successive elements of an array. If a complete sequence is received you would then need a piece of code that decides what action to take.


yes, i need one after the other


#include <Keypad.h>

const int LED_1 = 30;
const int LED_2 = 31;
const int LED_2 = 32;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {50, 48, 46, 44};
byte colPins[COLS] = {51, 49, 47, 45}; 

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup()
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(LED_3, OUTPUT);

void loop()
  char customKey = customKeypad.getKey();

That looks like a promising start.

It would be even better if you read the How to Use This Forum and put your code in code tags so it looks like this