I’m having a strange issue with the NodeMCU v2. Basically, I want to turn on an RGB led using the PWM pins on the board and setting the intensity of the red, green and blue pins with the pmw.write() function in order to pick a specific color. This is the simple code I used to test the led:
import pwm pinMode(D2, OUTPUT) # red pinMode(D5, OUTPUT) # green pinMode(D6, OUTPUT) # blue duty=0 while True: for i in range(-100, 100, 1): duty = 100-abs(i) pwm.write(D2.PWM, 100, duty, MICROS) pwm.write(D5.PWM, 100, duty, MICROS) pwm.write(D6.PWM, 100, duty, MICROS) sleep(10)
This should fade in and fade out the led (white color), but the problem is that it doesn’t seem to work well! The led starts flashing in a totally crazy way.
So, I decided to try the same code with another board, the ST Nucleo F401RE, and it runs flawlessly. Then again, I tried to use a very similar code in another IDE with the NodeMCU v2 to see if it was a problem with the hardware but, surprisingly, it worked well.
So, it seems like the problem is with Zerynth + NodeMCU v2 + PWM.
What do you suggest me to do?