Quick doubt, mapping POT values to mouseX

http://pastebin.com/ZqMp6gdU Please look line 64,65

This is my processing sketch. Instead of mapping to mouse, i'd like to control the interaction with my potentiometer. :grin:

-What changes shall i make in this code? So that i rotate the POT and the interaction happens accordingly.

This sketch increases frequency of a tone as you mouse mouse to right side on the screen.

Thanks :)

You need to do something "similar" to the way you read serial input on the Arduino. You've done the initialisation OK.

     while ( port.available() > 0) {
       inChar = port.read();         // read it and store it in val
       println(inChar) ;             // optional debugging
       if (inChar == 'd') {          // If the serial byte received is a "d"
         fill(50);                   // set fill to dark Gray
         rect( width/2, 0, width/2, height);
       if (inChar == 'u') {          // If the serial byte received is a "u"
         fill(200);                  // set fill to light Gray
         rect( width/2, 0, width/2, height);
     // Which implies that any other characters are simply ignored/discarded

This Processing code will colour a rectangle whenever the Arduino does a Serial.print('d') or Serial.print('u').

So in your Arduino loop you sample the POT and send a character (hint: Use Serial.write, not print) which the Processing port.read() receives as a binary number.