This library allows you to easily do IR proximity sensing on a Circuit Playground Express. Its Github repository is here.
Follow the directions here.
The library includes an example.
where threshold is the threshold between close and not close.
Returns if more IR light than the threshold was reflected.
void begin(int threshold)
Sets everything up.
void setThreshold(int threshold)
Sets the threshold once the Proximity object is declared.
Returns the current threshold.
Returns the amount of IR light reflected last time close() was called.