Ugh... can't believe I forgot that
Thanks a huge amount
... and hey, while I've got ya....
any idea how to make it stop moving when I release the key? (Processing?)
I thought this would work, and it does with a graphic in processing...
But the serial line would never STOP seeing the initial Char, any way to cancel it out?
(Release motors when keyReleased? Stutters when there's still an active keypressed?)
This part's complicated, I understand if you're done, helped a huge amount thanks!
Code: Select all
switch(COMPOSITOR) { //most important part, this is for sending composite movements
case 1: port.write("w"); break; //COMPOSITOR = forward=1, right=2, back=4, left=8;
case 2: port.write("d"); break;
case 4: port.write("s"); break;
case 8: port.write("a"); break;
}}
void keyPressed(){
OUTPUT = key;
switch(key) {
case('w'):case('W'): b =0; COMPOSITOR |= 1 ;break;
case('d'):case('D'): f =0; COMPOSITOR |= 2 ;break; //add(OR) COMPOSITOR if not that # already
case('s'):case('S'): e =0; COMPOSITOR |= 4 ;break;
case('a'):case('A'): d =0; COMPOSITOR |= 8 ;break; // |= (is OR statement, bitwise)
}}
void keyReleased(){ //abcdef are the key overlay masks for making the key "light up" when pressed
switch(key) {
case('w'):case('W'): b =150; COMPOSITOR ^= 1 ;break; // ^= (is XOR statement, bitwise)
case('d'):case('D'): f =150; COMPOSITOR ^= 2 ;break;
case('s'):case('S'): e =150; COMPOSITOR ^= 4 ;break;
case('a'):case('A'): d =150; COMPOSITOR ^= 8 ;break;
}}