RGB led problem
RGB led problem
guys I connected RGB led to an esp32 board but all 3 doesn't turn off after I turn them on on. and for example if i want to toggle the red 3 times and turn off it toggles 3 times but won't turn off it keeps on with out toggling. and this is the case for all 3 colors. can you tell me what the problem is ?
Last edited by wonde05 on Fri Apr 09, 2021 8:27 am, edited 1 time in total.
Re: question
People here are not very good at remote mind reading, so we need more technical details.
Please tell us,
- which RGB led you are use
- how you connected it to the ESP32 board and
- which python commands you used.
Please tell us,
- which RGB led you are use
- how you connected it to the ESP32 board and
- which python commands you used.
Re: question
i used 1554799RL common anode RGB and esp32_dev_kit-v4 board i connected red to gpio 17, green to gpio 15 and blue to gpio 23 through resistors of course and i used a simple python code
Code: Select all
from machine import Pin
from time import sleep
led = Pin(17,Pin.OUT)
for i in range (n): # this is just for the red
led.on()
sleep(0.5)
led.off()
sleep(0.5)
Re: question
Assuming you have the common anode at 3.3V it should work. Two notes:
- led.on() and led.off() are confusing API names, since led.on() switches the output to high level, and led.off() to low level. So led.off() should switch the led on, and the opposite. But it should switch. I prefer to specify the levels with led.value(1) and led.value(0)
- I am a little bit reluctant to use GPIO17, because that sometimes used for memory circuits. But at long as your board continues to run and the code does not report an error, it should be fine.
Edit: I re-edited your code a little bit. Besides whitespace I changed pin.OUT into Pin.OUT.
- led.on() and led.off() are confusing API names, since led.on() switches the output to high level, and led.off() to low level. So led.off() should switch the led on, and the opposite. But it should switch. I prefer to specify the levels with led.value(1) and led.value(0)
- I am a little bit reluctant to use GPIO17, because that sometimes used for memory circuits. But at long as your board continues to run and the code does not report an error, it should be fine.
Edit: I re-edited your code a little bit. Besides whitespace I changed pin.OUT into Pin.OUT.
Code: Select all
from machine import Pin
from time import sleep
led = Pin(17,Pin.OUT)
for i in range (n): # this is just for the red
led.on()
sleep(0.5)
led.off()
sleep(0.5)
Re: question
I tried different types of code it doesn't work may be the problem is with in the led it self. and yes the common anode is on 3.3v
this code should blink the led 3 times and stop it, after blinking 3 times it stops blinking but it doesn't turn off . its the same problem for all 3 color leds .
Code: Select all
from machine import Pin
from time import sleep
led = Pin(17,Pin.OUT)
for i in range (3): # this is just for the red
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
Re: question
Everything is fine. Just the way LED is connected, led.value(0) switched the led ON, led.value(1) switches it OFF.
Re: RGB led problem
I replaced by this
its works fine now thank you.
Code: Select all
from machine import Pin, I2C
from time import sleep
ledred = Pin(17, Pin.OUT)
ledblue = Pin(23, Pin.OUT)
ledgreen = Pin(15, Pin.OUT)
for i in range (3):
ledgreen.on()
sleep(0.5)
ledgreen.0ff()
sleep(0.5)
Code: Select all
from machine import Pin, I2C
from time import sleep
ledred = Pin(17, Pin.OUT)
ledblue = Pin(23, Pin.OUT)
ledgreen = Pin(15, Pin.OUT)
for i in range (3):
ledgreen.value(0)
sleep(0.5)
ledgreen.value(1)
sleep(0.5)
its works fine now thank you.