What do you mean by wall ? Would you like to draw like another rectangle in your scene with an hitbox ? If so, here is a suggestion.
int xPos = 25;
int yPos = 25;
int xPosN;
int yPosN;
int playerSize=15;
void setup() {
fullScreen();
}
void draw() {
background(75, 75, 75);
xPosN=xPos;
yPosN=yPos;
if(keyPressed)control();
fill(250, 0, 0);
rect(xPos, yPos, playerSize, playerSize);
if(!wall(50,50,50,50)) move();
}
void control() {
if (keyCode == LEFT || key == 'a') xPosN = xPos-2;
if (keyCode == RIGHT || key == 'd') xPosN = xPos+2;
if (keyCode == UP || key == 'w') yPosN = yPos-2;
if (keyCode == DOWN || key == 's') yPosN = yPos+2;
}
void move() {
xPos=constrain(xPosN,0,width-playerSize);
yPos=constrain(yPosN,0,height-playerSize);
}
boolean wall(int x, int y, int w, int h) {
fill(0, 250, 0);
rect(x, y, w, h);
return (xPosN+playerSize>x && xPosN<x+w && yPosN+playerSize>y && yPosN<y+h);
}