Hello!!!
I would like help to get my program running when a specific key on the matrix keyboard is pressed. I want the program to work, otherwise my program must not work. It would be great if I can view it on an LCD screen.
This is the English forum sectioon. Please reconsider Your posting or ask moderator to move Your post.
sure, thank you very much!!!
The common way is to put the specific key detection code in setup().
Leave setup() and start loop() when the right key is pressed.
Leo..
do you have any example?
Do you have any code that reads a matrix keyboard attached to your Arduino?
Post it and maybe we can see how to help you with your magic key.
a7
I have this code that is for a TDS conductivity sensor, I need to add the matrix keyboard to it so that at the beginning I can insert a maximum and minimum conductivity value of a substance, then with a specific key I must start the program, otherwise the program will not will work and the sensor will not detect the conductivity. It should be noted that the maximum and minimum values are only set to verify that the substance has a conductivity within the range.
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include "GravityTDS.h"
#define TdsSensorPin A0
GravityTDS gravityTds;
float temperature = 25, tdsValue = 0;
int rs = 10;
int e = A1;
int d4 = A2;
int d5 = A3;
int d6 = A4;
int d7 = A5;
LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
Serial.begin (9600);
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //voltaje de referencia en ADC, predeterminado 5.0V en Arduino UNO
gravityTds.setAdcRange(1024); //1024 para ADC de 10 bits; 4096 para ADC de 12 bits
gravityTds.begin(); //inicialización
}
void loop() {
//temperature = readTemperature(); //agrega tu sensor de temperatura y léelo
gravityTds.setTemperature(temperature); // establece la temperatura y ejecuta la compensación de temperatura
gravityTds.update(); //muestrear y calcular
tdsValue = gravityTds.getTdsValue(); // luego obtenemos el valor
lcd.setCursor(0, 0);
lcd.print("Conductividad =");
lcd.setCursor(0, 1);
lcd.print(tdsValue,0);
lcd.print("ppm");
}
and here I have a code for the LCD screen and the keyboard
#include <Keypad.h>
#include <LiquidCrystal.h>
int rs = 10;
int e = A1;
int d4 = A2;
int d5 = A3;
int d6 = A4;
int d7 = A5;
int numero = 0;
LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
const byte FILAS = 4;
const byte COLUM = 4;
char keys[FILAS][COLUM] = { //Definimos el Keymap
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPines[FILAS] = {2, 3, 4, 5};
byte colPines[COLUM] = {6, 7, 8, 9};
Keypad teclado = Keypad( makeKeymap(keys), rowPines,colPines,FILAS,COLUM);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Press any key...");
}
void loop() {
char tecla = teclado.getKey();
if(tecla){
lcd.clear();
lcd.print("Tecla oprimida:");
lcd.setCursor(0, 1);
lcd.print(tecla);
Serial.println("Tecla presionada"+String(tecla));
}
}
I'm not sure I understand what your problem is.
So I'll guess.
combine arduino sketches
for guidelines.
HTH
a7
Sorry, I hope I am clearer. I don't know how to make a program so that the text "MAXIMUM CONDUCTIVITY=" appears on the LCD screen and with the keyboard to enter the maximum conductivity value, for example "140 ppm", that is, on the keyboard it would look something like:
MAXIMUM Conductivity =
140ppm
After writing the maximum conductivity, it is erased from the screen and “MINIMUM Conductivity” appears and with the keyboard enter an example value “40 ppm”, that is, on the keyboard it would look like this:
MINIMUM conductivity=
40ppm
Afterwards the minimum value is deleted from the screen, and "Conductivity=" should appear on the screen and with my tds sensor I measure the water and the read conductivity should appear on the screen something like:
Conductivity=
100ppm
I hope you can help me, please
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.