Issues with digitalWrite and AnalogWrite

Hello everyone,

First time posting in here after a couple of times lurking in here Ahah

I recently started to work with Arduinos Nano 33 BLE as I was interested by the BLE possibilities and the relatively low form factor that is suitable for my applications.

The goal is to replace an Arduino UNO that is receiving pressure data (from a FSR sensor) and translating into vibration on small haptic motors. The code I wrote was working perfectly with the UNO, nothing to notice.

As it didn't work out of the box for the Nano 33 BLE I figured I might start with the basics, the blink function is working great and I can also control the RGB led with the analogWrite or digitalWrite.

My issue is that I'm not able to use those two functions (analogWrite/digitalWrite) with the digital pins. For example the sketch below is not working. I tried with several Nano 33 BLE but same observation with each of them

void setup() {

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT); 
  pinMode(4, OUTPUT); 
  pinMode(5, OUTPUT); 


void loop() {

  digitalWrite(2, HIGH); 
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH); 


  digitalWrite(2, LOW); 
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW); 


I saw a couple of topics talking about issues with using the two functions but nothing about this particular issue so if you have any suggestions I'm all ears !

Thanks for your help !!

Problem Solved, it was a simple issue with the motor not receiving enough current !
A simple 2N2222 transistor did the trick !

When you control a motor, make sure a floating pin does not cause you any issues. The Arduino framework is slightly incompatible with the mbedOS framework and causes the pins to float for a short amount of time.

You can use the mbedOS functions directly to avoid these issues. There are examples in the forum.

Thank you for the insight Klaus, I remember seeing a few scripts with mbedOs functions directly !

I'll look into it more deeply , mbedOS seems to not be that easy to master but I should get there eventually :wink: