A little further! I got time to try your solution and it did work!!
But now, I want to try to light up every led to "follow" the person, by means of the distance measured in with the ultrasonic sensor. Therefore, I purchased a IS31FL3731 driver, to be able to control multiple lights/leds (+/-40). I soldered a charlieplexed "matrix" i.e. the amount of lights I want to be lighten up, and tried the swirl example that comes with the IS31FL3731 library. This did work, so the matrix seems fine. Now I want to combine the ultrasonic distance with the led controller.
Therefore my question, can anyone help me with manually controlling individual lights, i.e. lighting up one led (I read something about allocating leds on the grid by the x and y, but I do not understand the example (added below)). When I'm able to control each led, I can combine the distance with map() with each led, was my reasoning.
Thank you all very much for the help!!
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_IS31FL3731.h>
// If you're using the full breakout...
Adafruit_IS31FL3731 ledmatrix = Adafruit_IS31FL3731();
// If you're using the FeatherWing version
//Adafruit_IS31FL3731_Wing ledmatrix = Adafruit_IS31FL3731_Wing();
// The lookup table to make the brightness changes be more visible
uint8_t sweep[] = {1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40, 60, 60, 40, 30, 20, 15, 10, 8, 6, 4, 3, 2, 1};
void setup() {
Serial.begin(9600);
Serial.println("ISSI swirl test");
if (! ledmatrix.begin()) {
Serial.println("IS31 not found");
while (1);
}
Serial.println("IS31 found!");
}
void loop() {
int i = 0;
for (uint8_t x=0; x<16; x++) {
for (uint8_t y=0; y<9; y++) {
ledmatrix.drawPixel(x, y, i++);
}
}
}