Processing no longer displaying image or sound

Hi, so I’m doing a project with arduino and processing. The arduino code is okay, but my processing code for some reason isn’t working right. It used to display an image as well as run a sound but now it does neither of those things and I have no idea why. The code is as follows. I would be so so grateful if somebody could help me with this.

import controlP5.;
import processing.sound.
;
SoundFile mySoundFile;
ControlP5 cp5;
import java.io.File;
import processing.opengl.;
PImage im;
boolean displayImage;
boolean var = true;
import processing.serial.
;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup()
{
String portName = Serial.list()[1];
myPort = new Serial(this, portName, 9600);
size(500, 500);
cp5 = new ControlP5(this);
selectInput(“Select a file to process:”, “fileSelected”);
cp5.addButton(“onOff”).setValue(0)
.setPosition(10,10).setSize(200,19);
}
void fileSelected(File selection) {
println("User selected " + selection.getAbsolutePath());
im = loadImage(selection.getAbsolutePath());
}
public void onOff(int val){
displayImage = !displayImage;
}
void draw()
{
background(0);
if ( myPort.available() > 0) {
String inBuffer = myPort.readStringUntil(10);
if (inBuffer != null) {
if(inBuffer.indexOf(“h”)!=-1){
boolean var = false;
println(var);
}
}
if (im != null){
if(displayImage){
image(im, 0, 30);
if (var == false){
mySoundFile = new SoundFile(this, “Vocaroo 29 Jan 2021 17_28_57 CST 12e5cJxlGN7j.mp3”);
mySoundFile.play();
}
}
}
}
}

Like I said, it worked before and then just decided to stop. My port is ok, and I have the sound file and everything uploaded correctly. The libraries are also installed. I’m really confused at this point. Anything would help.

In the conditional where you are checking for “h”, you have this:

boolean var = false;

That creates a new variable accessible only in the conditional block. I think you probably want to remove “boolean” so that the value of your global variable of the same name will get changed there.

var = false;

When I remove the boolean, it says that the var doesn’t exist. Do you know why this is and what I can do to prevent it from happening?

There are two places in the code posted above that start with “boolean var =”. Only the second one should be changed to just “var =”.

I changed the second one but it still didn’t work

It actually won’t even print out if it’s false or true. I’m really confused right now