Not able to blink blue led

I have a Raspberry Pi and an Arduino. I am trying to make them talk, so I uploaded the following sketch to the Arduino:

//Pi and Arduino
const int ledPin = 7;

void setup() {
  // put your setup code here, to run once:
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello pi");
  if(Serial.available()){
    flash(Serial.read());
    
  }
  delay(1000);
}
void flash(int n){
  for(int i = 0; i < n; i++){
    digitalWrite(ledPin, HIGH);
    delay(100);
  }
}

Then, in the Raspberry Pi python terminal, I typed this:

import serial 
see = serial.Serial('/dev/ttyACM0', 9600)

while true:
…    print(ser.readline())
…

Then, I got these messages(on the pi):

Hello Pi
Hello Pi
Hello pi 
etc.

I pressed CTRL-C and typed this: ser.write('5'.encode()) and it did not blink the led on pin five times. :confused: Can you help me?

This

void flash(int n){
  for(int i = 0; i < n; i++){
    digitalWrite(ledPin, HIGH);
    delay(100);
  }

only writes HIGH to the LED pin. It cannot possibly blink.

And .... doesn’t the pi run at 3.3volts ? - have you taken care of the differing voltage levels in however they talk?