works from processing to arduino but not other way
i've used method send x & y angles servos processing arduino on serial connection. however, when try send xy angles calculated accelerometer processing arduino can't work. know need use things "myport.read();" on processing instead of "serial.read();" on arduino. changed those, still can't processing code compile.
i want to:
send data arduino "serial.write(xangle+'x');"
and have processing incoming numbers , if they're followed either 'x' or 'y' act accordingly.
here's code works on arduino not processing:
the first issue keyword "static" isn't allowed reason. second issue "case '0'...'9':" won't compile. there more issues i'd moving in right direction here. advice appreciated. in advance.
i want to:
send data arduino "serial.write(xangle+'x');"
and have processing incoming numbers , if they're followed either 'x' or 'y' act accordingly.
here's code works on arduino not processing:
code: [select]
void loop() {
static int v = 0;
if ( serial.available()) {
char ch = serial.read();
switch(ch) {
case '0'...'9':
v = v * 10 + ch - '0';
break;
case 'x':
servox.write(v); //instead of servox.write() "xangle = v;"
v = 0;
break;
case 'y':
servoy.write(v); //instead of servoy.write() "yangle = v;"
v = 0;
break;
}
}
} the first issue keyword "static" isn't allowed reason. second issue "case '0'...'9':" won't compile. there more issues i'd moving in right direction here. advice appreciated. in advance.
if define v outside main loop static.
the case should be
the case should be
code: [select]
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v = v * 10 + ch - '0';
break;
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > works from processing to arduino but not other way
arduino
Comments
Post a Comment