Hi,
I'm beginner with arduino, so sorry if i do a stupid question. I have to do a project with arduino using a solenoide and keypad 4x4.
I want take the numbers entered by the user and store these nubmbers in an variable. I will take multiply this numbers for 1000, putting the result in the delay time.
this time of delay is the time of the solenoide stay open, but in this case i test with led 13 of arduino. But i can't do this, my code is not working,
i need help for this project, please
Here is my code
#include <Keypad.h>
String acumulado = " ";
float tempo, dlay;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS] [COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','D'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5}; // saida das linhas
byte colPins[COLS] = {6,7,8,9}; //saida das colunas
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
Serial.println("Digite a quantidade de agua desejada");
}
String descarga(){
char key = keypad.getKey();
switch(key){
case NO_KEY:
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case 'B': case 'C': case 'D':
Serial.print(key);
acumulado.concat(key);
break;
case '*':
Serial.print(key);
acumulado.concat(key);
tempo = acumulado.toFloat();
dlay = tempo * 1000;
if(key == 'A'){
digitalWrite(13, HIGH);
delay(dlay);
digitalWrite(13, LOW);
delay (dlay);
}
acumulado = " ";
break;
case '#':
Serial.print(key);
acumulado.concat(key);
acumulado = " ";
break;
}
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey();
Serial.print(key);
descarga();
}