arduino processing and bluetooth

Hello!

I am having issues getting data from arduino to processing through a hc-06 bluetooth module.
In this case I am just trying to get simple data across.

arduino code:

 int i=0;
        
        void setup()
        {
          Serial.begin(9600);
          
        }
        
        void loop()
        {
         Serial.write(i);
        
        i++;
        
        delay(200);
        
        if(i>255){
          
         i=0; 
        }
          
    }

processing code:

  import processing.serial.*;
        
        Serial myPort;
        
        int val=0;
        
        void setup()
        {
          println(Serial.list());
        
          String portName = Serial.list()[1];
        
          myPort = new Serial(this, portName, 9600);
          
        }
        
        
        
        void draw(){
          if ( myPort.available() > 0) {  
        
            val = myPort.read(); 
        
           println(val);
        
          delay(100); 
        
          }
          
          
        }

I recognized and added the HC-06 module on my laptop, and it created 2 (?) com ports, in my case 6 and 7. My arduino is listed as COM 3. When I print the available coms, I only get 3 and 7. When I select 3, I get the data but its through the cable, when I select 7 I get nothing.

Wiring:
vcc - 3.3v
grnd - grnd
tx- rx
rx - tx

Help is much appreciated!

Wiring:
vcc - 3.3v
grnd - grnd
tx- rx
rx - tx

Try connecting the bluetooth device to some other pins. Then, you can use SoftwareSerial to read from/write to the bluetooth device, and Serial to read from/write to the Serial Monitor application or other application on the PC. Don't disable the Serial instance by using it to talk to the bluetooth device.

Try connecting the other bluetooth port using below code:

String portName = Serial.list()[2];

or directly use this code ( without these code println(Serial.list()); String portName = Serial.list()[1]; )

myPort = new Serial(this, COM7, 9600);