Variable not found

You’re declaring your p1 variable inside the setup() function, so it’s only in scope inside the setup() function. Try to put together a simpler example:

function setup(){
  let x = 'hello';
}

function draw(){
  console.log(x); // won't work
}

If you want to reference a variable in multiple functions, you need to declare your variable outside of the functions:


let x;

function setup(){
  x = 'hello';
}

function draw(){
  console.log(x);
}