Test LED working or not by giving to Power.
If working remove and place it in GPIO Pin
led anode cathode
resistor one end gnd(6 or 9 or 14)
resistor other end: GPIO PIN(12,11)
https://youtu.be/CUCkzxIkZ80
->Led Anode(LargeLeg)with Resister 1 Leg
LED Cathode (Small Leg) with GND
Register another leg with GPIO
Code:-1
To import Raspberry from python
import RPi.GPIO //Using library's in Commands
import time //for giving delay
import RPi.GPIO as h //Short cut for reusing reducing length
h.setwarnings(False) //to avoid warinings
led=12
h.setmode(h.BOARD) //Board Mode (Sequence Numbers) or BCM MODE RED GREEN
h.setup(led,h.OUT)
h.output(led,1)
print("led on")
time.sleep(5) //given delay for lite to glow for every 5 seconds
h.output(led,0)
print("led off")
Code:-2 For Continues looping using while
To import Raspberry from python
import RPi.GPIO //Using library's in Commands
import time //for giving delay
import RPi.GPIO as h //Short cut for reusing reducing length
h.setwarnings(False) //to avoid warinings
led=12
h.setmode(h.BOARD) //Board Mode (Sequence Numbers) or BCM MODE RED GREEN
h.setup(led,h.OUT)
while 1:
h.output(led,1)
print("led on")
time.sleep(5) //given delay for lite to glow for every 5 seconds
h.output(led,0)
print("led off")
time.sleep(2)
CTL+C to Stop execution
To Run Same Script in Linux Shell
CTRL+Z to Stop Execution
pwd // present working directory
ls //list of files in directory
mkdir home/pi //Selecting specific location
To come back from pi top home
cd ..
To run a file
python Example1.py
No comments:
Post a Comment