0

I try to make a LED light up with the code enter image description here

 import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(18, GPIO.OUT) while (var==1): GPIO.output(18,GPIO.LOW) GPIO.cleanup() 

as illustrated in the figure, the pin 18 serves to light up a LED or switch it Down but when I try with sudo python3 this script I see that the LED is lighten just a bit. Only if I connect my transistor base to the ground, I see that the LED is off completely I conclude that pin 18 is between HIGH and LOW, ont completely LOW... why?

1
  • the LED is incorrectly oriented ... it will not light even if the transistor is bridged Commented Apr 5, 2021 at 23:55

1 Answer 1

2

It is unclear exactly what you have done (list full code & connections). What is R_US

The fundamental problem is your circuit.

Using an emitter follower is POOR practice; it will attempt to put 2.7V across the LED when ON, overloading the GPIO with unpredictable results. You have shown the LED connected in reverse.

Try a more conventional circuit; the LED & resistor in series would form the load. See https://elinux.org/RPi_GPIO_Interface_Circuits

NOTE with normal LED you can drive (up to 16mA) directly from the GPIO.

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.