In this series I am going to play around with LED's. These simple devices are just great to learn the basic's and even some advanced electronics.
This specific one is quite a simple one. Basically just making an LED switch on and off. Once again using the Rasperry Pi and its GPIO pins.
The ingredients:
- 1 x LED (Any colour)
- 1 x resistor (round the 250ohm mark)
- A few jump wires
Layout
Here we connect a jump lead (Red) from one of the GPIO Pins (18 in this case) to a resistor which in turn is connected to the anode (positive) end of the LED. The Cathode (negative) end of the LED is then connected to Ground, by the black jump lead.
The Code
import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) while True: GPIO.output(18, True) time.sleep(1) GPIO.output(18, False) time.sleep(1)
No comments:
Post a Comment