Gracias Por Los Aportes Compañeros, Me Eh Puesto A Leer Sobre String...
AunNo Comprendo Bien, Eh Tomado El consejo De Revisar Los Ejemplos en el Arduino
Este Es El Mas Apegado,
/*
String length()
Examples of how to use length() in a String.
Open the Serial Monitor and start sending characters to see the results.
created 1 Aug 2010
by Tom Igoe
http://arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
String txtMsg = ""; // a string for incoming text
int lastStringLength = txtMsg.length(); // previous length of the String
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// send an intro:
Serial.println("\n\nString length():");
Serial.println();
}
void loop() {
// add any incoming characters to the String:
while (Serial.available() > 0) {
char inChar = Serial.read();
txtMsg += inChar;
}
// print the message and a notice if it's changed:
if (txtMsg.length() != lastStringLength) {
Serial.println(txtMsg);
Serial.println(txtMsg.length());
// if the String's longer than 140 characters, complain:
if (txtMsg.length() < 140) {
Serial.println("That's a perfectly acceptable text message");
}
else {
Serial.println("That's too long for a text message.");
}
// note the length for next time through the loop:
lastStringLength = txtMsg.length();
}
}
Eh Tratado De Cambiar La Recepcion De Datos Por El De La Matriz Pero No Logro Dar, Mi Codigo Ahora Es,
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
String txtMsg = ""; // a string for incoming text
int lastStringLength = txtMsg.length(); // previous length of the String
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for Leonardo only
}
// send an intro:
Serial.println("\n\nString length():");
Serial.println();
}
void loop() {
// add any incoming characters to the String:
while (customKeypad.getKey() > 0) {
char inChar = customKeypad.getKey();
txtMsg += inChar;
}
if (txtMsg.length() != lastStringLength) {
Serial.println(txtMsg);
Serial.println(txtMsg.length());
if (txtMsg.length() < 140) {
Serial.println("That's a perfectly acceptable text message");
}
else {
Serial.println("That's too long for a text message.");
}
lastStringLength = txtMsg.length();
}
}
Cambie El
while (Serial.available() > 0) {
char inChar = Serial.read();
txtMsg += inChar;
Por Esta Parte Segun Mi Logica, En Vez De Leer Serial Leer La Matriz (aqui eh de estar mal...)
while (customKeypad.getKey() > 0) {
char inChar = customKeypad.getKey();
txtMsg += inChar;
Cuando Lo Ejecuto Y Trato De Escribir En La Matriz Aparece El El Contador De Caracteres Mas No El Introducido Desde La Matriz..
Algun Dato Que Me Puedan Dar? Saludos Y Gracias Por Comentar