HI,
i wonna use a three button as a keypad that cand do 3 actions.
(the println is only for checking the input)
that is the code:
#include <Keypad.h>
const byte rows=3;
const byte cols=1;
char keys[rows][cols]={'1','2','3'}; // keypad set
byte rowpin[rows]={2,3,4};
byte colpin[cols]={5};
Keypad choice = Keypad(makeKeymap(keys),rowpin,colpin,rows,cols);
int led = 13;
int led2 = 12; // output set
int led3 = 11;
void setup() {
pinMode(led,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
}
void loop() {
digitalWrite(led,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
char choix = choice.getKey(); //value get
switch(choix){
case 1:
digitalWrite(led,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
case 2:
digitalWrite(led,LOW);
digitalWrite(led2,HIGH); // NO OUTPUT
digitalWrite(led3,LOW);
case 3:
digitalWrite(led,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;}
}
:o than How to keep the keypad value until another value commes???