Loading...
Logo
Processing Forum
bpetersenri's Profile
1 Posts
0 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    I am using
    • Windows 7
    • Arduino MEGA ADK
    • I have ran everything as administrator and I got rid of UAC.
    • I have temporarily disabled Anti-virus and re-ran the program
    • Com port is COM3

    Everything I do in Arduino works fine. I can read, write and all the other Serial functions with Arduino.
     
    My problem comes with Processing; for some reason I can not write to the port. I can read the port though. 

    I am following the example code verbatim; I just took out the comments to make it easier to read.

    When I run Serial.list()[0] I get only 1 option: "COM3". I have tried the code with Serial.list()[0] and "COM3".

    If I change brightness = Serial.read(); --> brightness = Serial.parseInt(); I can just type in a number between 0 and 255 and it changes the brightness accordingly.

    Can someone help figure out why I can not write to the "COM3" Port with Processing?

    Arduino Code:
    1. const int ledPin = 9;

      void setup()
      {
        Serial.begin(9600);
        pinMode(ledPin, OUTPUT);
      }

      void loop() {
        byte brightness;

        if (Serial.available()) {
          brightness = Serial.read();
          analogWrite(ledPin, brightness);
        }
      }
    Processing Code:
    1. import processing.serial.*;
       Serial port;
       
       void setup() {
       size(256, 150);
       
       println("Available serial ports:");
       println(Serial.list());
       
       port = new Serial(this, Serial.list()[0], 9600); 
       
       }
       
       void draw() {
       for (int i = 0; i < 256; i++) {
       stroke(i);
       line(i, 0, i, 150);
       }
       
       port.write(mouseX);
       }