Sorry here is this code again:
I just want to implement the idea: if the users inputs 20 it will turn pin13 high for a period of time and when the user inputs 200 it will turn pin 13 high for a longer period than the 20 case.
As I mentioned in my previous post. My code is not complete. Yes I need to declare pin 13. But for now I just trying to get something from the input and later I'll use the input to do what I want.
I am just having problem.
I want to get and integer 20 when user inputs 20 and integer 200 when user inputs 200.
Thank
[#include <Keypad.h>
//new code start here
int k, amCount=0;
//new code end here
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{
'1','2','3' }
,
{
'4','5','6' }
,
{
'7','8','9' }
,
{
'*','0','#' }
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {
9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {
12, 11, 10 };
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 13
void setup()
{
digitalWrite(ledpin, HIGH);
Serial.begin(9600);
}
void loop()
{
char key = kpd.getKey();
if(key) // Check for a valid key.
{
switch (key)
{
case '100':
digitalWrite(ledpin, LOW);
break;
case '3':
digitalWrite(ledpin, HIGH);
break;
default:
Serial.println(key);
}
}
}
]