Arduino, as a SCOPE

hi
I´m doing a proyect, and i need use a scope; i found this code:

import processing.serial.Serial;
import processing.serial.*;

Serial myPort;
int xPos=1;

void setup (){
  size(400,300);
  
  println(Serial.list()); //here is the error

  myPort = new Serial(this,Serial.list()[0],9600);
  //myPort.bufferUntil ('\n');
  background(0);
             }
void draw () {
 
             }
void serialEvent(Serial myPort){
  
  String inString = myPort.readStringUntil('\n');
  
  if (inString != null){
    
    inString=trim(inString);
    
    float inByte = float(inString);
    inByte = map(inByte,0,1023,0,height);
    
    stroke(127,34,255);
    line(xPos,height, xPos,height-inByte);
    
    if(xPos>=width){
      xPos = 0;
      background(0);
                   }
    else{
      xPos++;
        }
                       }
                               }

Processing 3.5.3 show me this:
Type String[] of the last argument to method println(Object…) doesn’t exactly match the vararg parameter type. Cast to Object[] to confirm the non-varargs invocation, or pass individual arguments of type Object for a varargs invocation.

and don´t show the signal tested.what should i do?

1 Like

Please go back and edit your post, select your code and hit the </> button to format your text as code. As it is right now, some characters might be missing. We need to see a fully formatted code to address this issue.

What line shows the error at by the way?

Kf

Also, you are drawing inside your serialEvent() function. Accessing your canvas should be done inside your draw(). In other words, move anything that touches the sketch to draw().

Kf

1 Like

the error appears at the 10th line

the measured value on a arduino might be 0 … 1023
same as you suggest in the map function.
so i see no use to try to convert that value from string into a float.

anyhow i recommend that you print that ( cleaned up ) string to console first
to see what you really get from serial port.
/ and if it match with what you see in the arduino IDE monitor,
after upload your arduino sketch

You should use printArray() based on this link.

Kf

Were you able to resolve this issue?
and get your processing/arduino scope running?