hola!, tengo un problema, quiero hacer una conexion con arduino y processing, la idea es que arduino lea el texto que haya escrito el usuario en processing y que el arduino lo lea(un 1 enciende led, el 0 nada), el problema es que tambien quiero que processsing lea lo escrito por el usuario e imite que enciende luces o algo asi (circulos, cuadrados, etc). pero no se como hacerlo, eso si llevo esto el primero es el codigo de arduino y el segundo de processing:
ARDUINO:
String binario[] = {"01000001", "01000010", "01000011", "01000100", "01000101", "01000110", "01000111",
"01001000", "01001001", "01001010", "01001011", "01001100", "01001101", "01001110", "01001111", "01010000", "01010001",
"01010010", "01010011", "01010100", "01010101", "01010110", "01010111", "01011000", "01011001", "01011010",
"01100001", "01100010", "01100011", "01100100", "01100101", "01100110", "01100111", "01101000", "01101001", "01101010",
"01101011", "01101100", "01101101", "01101110", "01101111", "01110000", "01110001", "01110010", "01110011", "01110100",
"01110101", "01110110", "01110111", "01111000", "01111001", "01111010", "01000000"
};
char abc1[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U'
, 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', ' '
};
char poema [] = "";
String poema1 = "";
void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
poema1 = String(Serial.read());
for (int x = 0 ; x < poema1.length(); x++) {
for (int r = 0; r <= 53; r++) {
for (int e = 0; e < 8; e++) {
if (abc1[r] == poema[x]) {
String t = binario[r].substring(e, e + 1);
if (t == "1") {
digitalWrite(e + 6, HIGH);
}
if (e == 7) {
delay(1000);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
}
}
}
}
}
}
PROCESSING:
import processing.serial.*;
Serial port;
int data;
char letter;
String words = "";
void setup() {
size(520, 600);
textFont(createFont("Georgia", 36));
println(Serial.list());
port=new Serial (this, "COM4", 9600);
}
void draw() {
background(#49C3FA);
fill(255);
rect(10, 10, 500, 200);
fill(0);
textSize(14);
text("¿Qué piensas?", 50, 50);
text("Letra: " + letter, 50, 70);
text("Caracteres " + words.length(), 50, 90);
text("Máximo 141 caracteres", 50, 110);
textSize(14);
text(words, 50, 120, 440, 200);
}
void keyPressed() {
if ((key>='A'&&key<='z')|| key == ' '||key==TAB){
letter = key;
println(key);
words=words + key;
}
if (key==BACKSPACE){
words="";
println(words);}
if(key==ENTER)
port.write(key);
}
desde ya muchas gracias por haberlo leido, y si me pueden ayudar aun mas
![]()