WEBVTT

00:00.000 --> 00:12.000
learning objective hardware components circuit setup Python code for LED

00:12.000 --> 00:18.680
control troubleshooting objective is to verify that the raspberry pi OS is

00:18.680 --> 00:27.440
functioning properly by observing a blinking LED components raspberry pi with

00:27.440 --> 00:34.880
OS installed an SD card inserted breadboard jumper wires male to female or

00:34.880 --> 00:42.320
others that are compatible with your setup LED any color note polarity resistor

00:42.320 --> 00:50.080
220 ohms to 1 kilo circuit setup important do not power the raspberry pi

00:50.080 --> 00:55.600
until after all wiring is complete place the LED on the breadboard insert the

00:55.600 --> 01:01.280
longer leg a note of the LED into one row of the breadboard insert the shorter

01:01.280 --> 01:06.440
leg cathode into an adjacent row connect one end of the resistor to the

01:06.440 --> 01:11.460
shorter leg cathode of the LED on the breadboard the other end of the

01:11.460 --> 01:17.400
resistor will go to the GPI pin connect to raspberry pi use a jumper wire

01:17.400 --> 01:24.160
breadboard connections to connect the free end of the resistor to GPIO 17 on

01:24.160 --> 01:32.640
the raspberry pi GPIO header physical pin may differ but the GPIO label is 17 use

01:32.640 --> 01:38.000
another jumper wire to connect the longer leg a node of the LED to a ground

01:38.000 --> 01:46.440
G and D pin on the raspberry pi the longer leg a node of the LED typically goes to

01:46.440 --> 01:52.320
a positive or a higher potential in this case G and D is at zero volts but we

01:52.320 --> 01:57.080
are driving the LED by pulling the GPIO pin high and the LED is reversed in

01:57.080 --> 02:01.640
hardware this is only fine as long as the code accounts for it by inverting the

02:01.640 --> 02:11.680
on eye off logic the shorter leg cathode goes through the resistor to the GPI

02:11.680 --> 02:18.800
pin this wiring is a bit reversed from a typical LED to 3.3 volts resistor to

02:18.800 --> 02:23.960
ground approach but it will still work if the code sets the pin high to turn the

02:23.960 --> 02:30.080
LED off and low to turn it on if you prefer the more common approach swap the

02:30.080 --> 02:35.240
connections so that the GPIO pin goes to the LED's longer leg through the

02:35.240 --> 02:41.200
resistor and the shorter leg goes to G and D then adjust the code accordingly

02:41.200 --> 02:47.640
writing the Python code open thawney pre-installed IDE click the raspberry pi

02:47.640 --> 02:54.920
start menu programming thawney Python IDE installed GPIO zero or use rpi dot

02:54.920 --> 03:01.240
GPIO the example uses the rpi dot GPIO library which is typically pre-installed

03:01.240 --> 03:11.360
on raspberry pi OS create a new Python file in thawney click file new and type in

03:11.360 --> 03:16.000
the provided code and understand the working of this code importing the

03:16.000 --> 03:22.400
pre-installed rpi GPIO library to program the GPIO and time to control the

03:22.400 --> 03:29.840
delays then setting the board mode of the raspberry pi to Broadcom BCM setting

03:29.840 --> 03:37.520
the LED pin to GPIO 17 is the physical pin 11 in Broadcom mode and the

03:37.520 --> 03:41.800
blinking logic with the delay time passed through the time dot sleep function

03:41.800 --> 03:47.200
feel free to change it as you like you can observe here that we've added print

03:47.200 --> 03:52.400
statements as a means of debugging and pinpointing the error when it occurs

03:52.400 --> 03:57.840
throwing in an exception with the keyboard interrupt function control plus

03:57.840 --> 04:04.360
C finally it's important to reset the GPIO using the GPIO cleanup function

04:04.360 --> 04:11.280
adjust the pin number if needed if you used a different GPIO pin eG GPIO 18

04:11.280 --> 04:18.960
update LED pin to that number run the script click run in thawney observe the

04:18.960 --> 04:23.640
LED blinking on and off according to the attributes passed in the sleep

04:23.640 --> 04:30.840
function a troubleshooting check wiring ensure the LED is placed correctly and

04:30.840 --> 04:36.800
the resistor is in series check pin number make sure the code pin LED pin

04:36.800 --> 04:43.680
matches the physical GPIO pin used LED orientation if the LED never lights

04:43.680 --> 04:51.520
reverse the LED connections we successfully set up a blinking LED using

04:51.520 --> 04:57.480
raspberry pi verifying the OS and GPI functionality keep experimenting with

04:57.480 --> 05:00.440
different configurations

