Hi everyone !
I'm new in the arduino's world (and i'm frensh so sorry for my bad English) and I've a programmation problem.
I want to make blink the led 3 times in the same color when it's light.
How can I make a pause until I press a button on Keypad ?
I've try the do/while but it don't listen the Keypad or don't get stuck by the loop and continue ..
Here is my programme that work but without the option I want to add :
#include <Keypad.h>
#define RED 12
#define GREEN 11
#define BLUE 10
int led=12;
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] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
pinMode(RED,OUTPUT);
pinMode(BLUE,OUTPUT);
pinMode(GREEN,OUTPUT);
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
int a =(customKey);
Serial.println(a);
}
int a = (customKey);
//if press the "1" button, led blue for 5s
if (a==49) {
digitalWrite(BLUE,HIGH);
delay(5000);
digitalWrite(BLUE,LOW);
}
//if press the "2" button, led red for 5s
if (a==50){
digitalWrite(RED,HIGH);
delay(5000);
digitalWrite(RED,LOW);
}
//if press the "3" button, led green for 5s
if (a==51){
digitalWrite(GREEN,HIGH);
delay(5000);
digitalWrite(GREEN,LOW);
}
}
I don't know if it's clear but I hope you could help me.
Thank you in advance !