We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi im really new in Processing and Arduino. I made a project for University last semester, we didnt had enough time in the end so our teachers helped us with the program. And now it doent work anymore :/ my projekt is like a drum kit with 64 buttons. the arduino part works good, i think the problem is my processing sketch doesnt read the serial right, and like i said i have no clue what i can do now maybe u can help me. Processing receives in serial something like "Button: Button: 1 0 1" for example the first number is row the second column and the last is 0 or 1 for on or off. Would be nice if somebody can help me.
Greetings dom
/E. sorry for the messy copy. dont know how to fix this
//Here is the problem i think
void serialEvent(Serial p) { try {
// get message till line break (ASCII > 13)
String message = p.readStringUntil(13);
// just if there is data
if (message != null) {
println(message);
// try catch function because of possible garbage in received data
String[] elements = splitTokens(message);
// loop through sensor values
if(elements[2].equals("0"))
matrix[parseInt(elements[0])][parseInt(elements[1])] = false;
if(elements[2].equals("1"))
matrix[parseInt(elements[0])][parseInt(elements[1])] = true;
}
} catch (Exception e) { } }
//
Answers
In order to have some code block displayed properly in this forum, we gotta highlight it and hit CTRL+K!
Since Serial doesn't work for me and neither got an Arduino myself I can't help ya!
Nevertheless, gonna leave ya w/ some points:
13
, it's much preferred meaningful constants.13
, use'\r'
orRETURN
.'\n'
orENTER
in case'\r'
ends up failing ya down.A futile attempt of mine below: