Error in sample code for a DC Motor

I have a project using this motor spinning to spin a rod. I’m just trying to get the motor to work. I’m using an Arduino UNO Wi-Fi Rev 2. The website link shows a picture of how I connected my wires to the Arduino. I connected wires 2 and 5 to a 12V DC Battery Power Supply. I connected wire 1 in pin 10, wire 3 in pin 11 and wire 4 in pin 9 on the Digital PWM~ side. I’m not really sure how to fix this error because I don’t really know this coding language well.

My error message:

/Users/margotclyburn/Documents/Arduino/motorex1sketch/motorex1sketch.ino: In function ‘void loop()’:
motorex1sketch:16:26: error: cannot convert ‘bool’ to ‘PinStatus’ for argument ‘2’ to ‘void digitalWrite(pin_size_t, PinStatus)’
digitalWrite(10, flag);
^
exit status 1
cannot convert ‘bool’ to ‘PinStatus’ for argument ‘2’ to ‘void digitalWrite(pin_size_t, PinStatus)’

Here is the sample code I input:

int i = 0;
unsigned long time = 0;
bool flag = HIGH;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(10, OUTPUT); //PWM PIN 10  with PWM wire
  pinMode(11, OUTPUT);//direction control PIN 11 with direction wire
}

void loop() {
  // put your main code here, to run repeatedly:
  if (millis() - time > 5000)  {
    flag = !flag;
    digitalWrite(10, flag);
    time = millis();
  }
  if (Serial.available())  {
    analogWrite(11, Serial.parseInt());  //input speed (must be int)
    delay(200);
  }
  for(int j = 0;j<8;j++)  {
    i += pulseIn(9, HIGH, 500000); //SIGNAL OUTPUT PIN 9 with  white line,cycle = 2*i,1s = 1000000us,Signal cycle pulse number:27*2
  }
  i = i >> 3;
  Serial.print(111111 / i); //speed   r/min  (60*1000000/(45*6*2*i))
  Serial.println("  r/min");
  i = 0;
}

website I got the code from: FIT0441_Brushless_DC_Motor_with_Encoder_12V_159RPM-DFRobot

Motor: Brushless DC Motor with Encoder 12V 159RPM
Battery Power Supply: 12V DC Battery Power Supply - 8-Cell AA Battery Holder | Super Bright LEDs

you are declaring 'flag' as a bool but the digitalWrite() function doesn't want a bool for the second argument. Change your flag to an int or byte type

You are experiencing the problem described here

But the API that comes with Arduino IDE 1.8.9 is different. It declares digitalWrite as

void digitalWrite(uint8_t, uint8_t);

It does not have this problem.

What exactly are you using to compile your code? Arduino IDE?

Montmorency:
But the API that comes with Arduino IDE 1.8.9 is different. It declares digitalWrite as

void digitalWrite(uint8_t, uint8_t);

It does not have this problem.

By "the API that comes with Arduino IDE 1.8.9", you are referring to the bundled Arduino AVR Boards core. Uno WiFi Rev2 does not use Arduino AVR Boards. It uses Arduino megaAVR Boards, which is the first core to use ArduinoCore-API:

Thus is serves as our preview of what could happen if ArduinoCore-API was integrated into the more commonly used cores with the current PinStatus enum system in place. However, the Arduino developers are now aware of the issue and I think they understand it needs to be resolved before that happens.