#include <EEPROM.h>
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
int An, An0, X=0, Y=0, Y1, Pr = 0, Cont0 = 0, SL = 0;
//define los caracteres de la matriz
char teclas [4] [4] = {{'1', '2', '3','A'},
{'4', '5', '6','B'},
{'7', '8', '9','C'},
{'*','0', '#', 'D'}};
char letras [4] = {'E', 'F', 'G', 'H'};
int cont, cont1;
//define los pines
int filas [ ] = {2,3,4,5};
int columnas [ ] = {6,7,8,9};
int botones [ ] = {10,11,12,13};
volatile int direccion = 0; //posicion de memoria nro 0
float valor; //variable que guarda el valor
void setup(){
Serial.begin(9600);
//Define el estado de los pines
for (cont=0 ; cont<=3 ; cont++){
pinMode(filas[cont ],OUTPUT);}
for (cont=0 ; cont<=3 ; cont++){
pinMode(columnas[ cont ],INPUT_PULLUP);}
for(cont=0; cont<=3; cont++){
pinMode(botones[cont], INPUT_PULLUP);}
}
//Arreglo que lee las teclas
void lectura () {
for (cont=0; cont<4; cont++){
digitalWrite (filas [cont], LOW);
for (cont1=0; cont1<4; cont1++){
if (digitalRead (columnas[cont1])== LOW){delay(50);
if (digitalRead (columnas[cont1])== LOW){
Serial.println(teclas[cont][cont1]); //muestra el caracter correspondiente
valor = teclas [cont][cont1]; //guardamos el valor en la variable value
EEPROM.put (direccion, valor); //Grabamos
direccion+ = sizeof(float); //Obtener
if(direccion = EEPROM.length()) direccion = 0; //Comprobar y reiniciamos y es necesario
while(digitalRead (columnas[cont1])== LOW){}
}
}}
digitalWrite (filas[cont], HIGH);
}
}
//Areglo que lee los botones
void lectura2 (){
for (cont=0; cont<4; cont++){
if (digitalRead (botones[cont]) == LOW){delay(50);
if (digitalRead (botones[cont]) == LOW){
Serial.println(letras[cont]); //muestra el caracter correspondiente
while(digitalRead (botones[cont]) == LOW) {}
Value = letras [cont]; //guardamos el valor en la variable value
EEPROM.put ( direccion, Value ); //Grabamos
direccion+ = sizeof(float); //Obtener
if(direccion = EEPROM.length()) direccion = 0; //Comprobar y reiniciamos y es necesario
}
}
}
}
void guardar(){
}
void loop (){
lectura();
lectura2 ();
}
Please show your exact error message
Welcome to the forum.
It means that there is an invisible character somewhere. This happens sometimes when code is copied from a webpage or is typed into a document editor.
When I copy your code to the Arduino IDE, then I don't get that error message.
I do get other errors:
This is not possible. I suppose that you want the '+=' operator :
direccion+ = sizeof(float);
The variable "Value" does not exit. Do you mean "valor" here:
Value = letras[cont];
I suppose you need "==" here, instead of "=" :
if(direccion = EEPROM.length())
The easy solution to getting rid of the stray characters is to post your code on here, then copy that code from the forum and past it into the IDE. The website removes the stray characters.
#include <EEPROM.h>
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
int An, An0, X = 0, Y = 0, Y1, Pr = 0, Cont0 = 0, SL = 0;
//define los caracteres de la matriz
char teclas [4] [4] = {{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
char letras [4] = {'E', 'F', 'G', 'H'};
int cont, cont1;
//define los pines
int filas [ ] = {2, 3, 4, 5};
int columnas [ ] = {6, 7, 8, 9};
int botones [ ] = {10, 11, 12, 13};
volatile int direccion = 0; //posicion de memoria nro 0
float valor; //variable que guarda el valor
void setup() {
Serial.begin(9600);
//Define el estado de los pines
for (cont = 0 ; cont <= 3 ; cont++) {
pinMode(filas[cont ], OUTPUT);
}
for (cont = 0 ; cont <= 3 ; cont++) {
pinMode(columnas[ cont ], INPUT_PULLUP);
}
for (cont = 0; cont <= 3; cont++) {
pinMode(botones[cont], INPUT_PULLUP);
}
}
//Arreglo que lee las teclas
void lectura () {
for (cont = 0; cont < 4; cont++) {
digitalWrite (filas [cont], LOW);
for (cont1 = 0; cont1 < 4; cont1++) {
if (digitalRead (columnas[cont1]) == LOW) {
delay(50);
if (digitalRead (columnas[cont1]) == LOW) {
Serial.println(teclas[cont][cont1]); //muestra el caracter correspondiente
valor = teclas [cont][cont1]; //guardamos el valor en la variable value
EEPROM.put (direccion, valor); //Grabamos
direccion += 4; //Obtener
if (direccion == EEPROM.length()) direccion = 0; //Comprobar y reiniciamos y es necesario
while (digitalRead (columnas[cont1]) == LOW) ;
}
}
}
digitalWrite (filas[cont], HIGH);
}
}
//Areglo que lee los botones
void lectura2 () {
for (cont = 0; cont < 4; cont++) {
if (digitalRead (botones[cont]) == LOW) {
delay(50);
if (digitalRead (botones[cont]) == LOW) {
Serial.println(letras[cont]); //muestra el caracter correspondiente
while (digitalRead (botones[cont]) == LOW) ;
char Value = letras [cont]; //guardamos el valor en la variable value
EEPROM.put ( direccion, Value ); //Grabamos
direccion += sizeof(float); //Obtener
if (direccion == EEPROM.length()) direccion = 0; //Comprobar y reiniciamos y es necesario
}
}
}
}
void guardar() {
}
void loop () {
lectura();
lectura2 ();
}
Looks like quite a few people know something about that when you do a quick search here on the forum:
#include <EEPROM.h>
byte Fil[4] = {4,5,6,7};
byte Col[4] = {8,9,10,11};
int Bot[4] = {2,3,12,13};
char Teclas[4][4] =
{{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}};
unsigned char val;
int eeAddress;
int IIndice = 0;
int Key = 1000;
void setup() {
Serial.begin (9600);
if(EEPORMM.Read(1023) != Key){
eeAddress = 4;
}
pinMode (2, INPUT_PULLUP);
pinMode (3, INPUT_PULLUP);
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (11, OUTPUT);
pinMode (12, INPUT_PULLUP);
pinMode (13, INPUT_PULLUP);
}
int X, Y, Cont0, Check, Res = 0, CT, CT1, CT2, CT3, CT4;
void loop() {
Check = 0;
for(Y = 0;Y <= 3;Y++){
digitalWrite(Col[Y], LOW);
}
for(Cont0 = 0;Cont0 <= 3; Cont0 ++){
Check = Check + digitalRead(Fil[Cont0]);
}
for(Y = 0;Y <= 3;Y++){
digitalWrite(Col[Y], HIGH);
}
if(Check != 4){
for(Y = 0;Y <= 3;Y++){
digitalWrite(Col[Y], LOW);
for(X = 0;X <= 3;X ++){
if((digitalRead(Fil[X]) == 0)&&((Res != X + Y * 4)||(CT == 0))) delay(50);
if((digitalRead(Fil[X]) == 0)&&((Res != X + Y * 4)||(CT == 0))){
Serial.println(Teclas[X][Y]);
EEPROM.Write(eeADDress, Teclas[X][Y]);
eeAddress += sizeof(char);
Res = X + Y * 4;
}
}
digitalWrite(Col[Y], HIGH);
}
CT = 1;
}
else CT = 0;
if((digitalRead(2) == 0)&&(CT1 != 1)) delay(50);
if((digitalRead(2) == 0)&&(CT1 != 1)){
Serial.println("Primer Tecla");
CT1 = 1;
}
else if(digitalRead(2) == 1)CT1 = 0;
if((digitalRead(3) == 0)&&(CT2 != 1)) delay(50);
if((digitalRead(3) == 0)&&(CT2 != 1)){
Serial.println("Segunda Tecla");
CT2 = 1;
}
else if(digitalRead(3) == 1)CT2 = 0;
if((digitalRead(12) == 0)&&(CT3 != 1)) delay(50);
if((digitalRead(12) == 0)&&(CT3 != 1)){
Serial.println("Tercer Tecla");
CT3 = 1;
}
else if(digitalRead(12) == 1)CT3 = 0;
if((digitalRead(13) == 0)&&(CT4 != 1)) delay(50);
if((digitalRead(13) == 0)&&(CT4 != 1)){
Serial.println("Cuarta Tecla");
CT4 = 1;
}
else if(digitalRead(13) == 1)CT4 = 0;
}
what microcontroller are you using?
in the Arduino IDE select File>Preferences and enable "Verbose output during Compiling and upload" then compile your program again
click "COPY ERROR MESSAGES" and upload the error messages as text
Since @santiorlando is reporting the same error with the same code as @leandrotejado, I've merged the two topics.
@santiorlando and @leandrotejado are you working together on a project or something? If so, please coordinate your use of the forum in the future so that you don't waste the time of the people who provide free assistance here.
\240 is HTML ... when you copy/pasted your code from an HTML document, you picked this "non-breaking space" up. Try pasting your code into a rudimentary editor (gedit, notepad) and save as .txt, then copy/paste the code again.
Thank you! that is very helpful!
Thank you!
I´m really sorry, we didn´t know exactly how to use this because it was our first time using it.
Yeah!, that's what we did and it was very helpful, thanks!!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.