Creating a pattern using p5.js then outputting it over arduino.

I have set up a project where by typing in the serial monitor my arduino will play a pattern of analog writes and delays through a simple DC motor. What I want to achieve is using something I made on p5.js which allows me to create a 10 step pattern of values, I want to be able to take the pattern as a Json put it on a micro sd card plug it in to arduino and have the arduino to play the json pattern on the micro sd card through the motor. I know I'll need to use ArduinoJSON but I have no idea where to start on actually getting the micro sd card adapter to work and on how to make the motor use the values from the json to play the pattern. Any help would be much appreciated.

int motorPin = 3;

void setup() {
 Serial.begin(9600);
 pinMode(motorPin, OUTPUT);
 while (! Serial);
 Serial.println("Speed 0 to 255");
}

void loop() {
 String input = "";
  while (Serial.available()){
    input = Serial.readString();
    delay(5);
  }
  /*if (Serial.available()) {
    int speed = Serial.parseInt();
    if (speed >= 50 && speed <= 255) {
      analogWrite(motorPin, speed);
    }*/
    input.trim();
    if (input == "Play"){
    analogWrite(motorPin, 50);
    delay(1000);
    analogWrite(motorPin, 100);
    delay(1000);
    analogWrite(motorPin, 150);
    delay(1000);
    analogWrite(motorPin, 200);
    delay(1000);
    analogWrite(motorPin, 255);
    delay(1000);
    analogWrite(motorPin, 150);
    delay(1000);
    analogWrite(motorPin, 250);
    delay(1000);
    analogWrite(motorPin, 50);
    delay(1000);
    analogWrite(motorPin, 100);
    delay(1000);
    analogWrite(motorPin, 0);
    }
    else if (input == "255"){
      analogWrite(motorPin, 255);
      delay(10000);
      analogWrite(motorPin, 0);
    }
  }

this is what I've got so far. It's disgustingly simple but I'm pretty new to arduino so am struggling with anything other that isn't simple atm.

this is the p5.js sketch aswell

It starts with what arduino do you have? a Uno? If so, you can purchase a data logging shield that will come with an SD or micro SD card slot. This will allow the arduino to interact with the SD card.

If you install the SD library, there are lots of examples on how to read a file from the card which you will need to do and then parse the JSON and then send commands to the motor based on the values stored in the file.

Awesome yeah forgot to specify what board I was using aha. I am using an uno I'll look into getting that shield I have a micro SD card adapter but if there's a shield that does that job that would make my life a lot simpler. Thank you