Presentation is loading. Please wait.

Presentation is loading. Please wait.

WORKSHOP LED CONTROL.

Similar presentations


Presentation on theme: "WORKSHOP LED CONTROL."— Presentation transcript:

1 WORKSHOP LED CONTROL

2 Things you need 1 Breadboard 5 LED 5 220 ohm resistor
Male-Female & Male-to-Male Jumper wires

3 LED LED stands for Light Emitting Diode, and glows when electricity is passed through it. RESISTOR You must ALWAYS use resistors to connect LEDs up to the GPIO pins of the Raspberry Pi. The Raspberry Pi can only supply a small current (about 60mA). The LEDs will want to draw more, and if allowed to they will burn out the Raspberry Pi.

4 WIRE FEMALE-TO-MALE: MALE-TO-MALE:
Jumper wires are used on breadboards to ‘jump’ from one connection to another. The ones you will be using in this circuit have different connectors on each end. FEMALE-TO-MALE: MALE-TO-MALE:

5 BREADBOARD The breadboard is a way of connecting electronic components to each other without having to solder them together.

6 Building the Circuit Use one of the jumper wires to connect a ground pin to the rail, marked with blue, on the breadboard. The female end goes on the Pi's pin, and the male end goes into a hole on the breadboard. Then connect the resistor from the same row on the breadboard to a column on the breadboard, as shown in the right. Next, push the LEDs legs into the breadboard, with the long leg (with the kink) on the right. Lastly, complete the circuit by connecting pin 18 to the right hand leg of the LED. This is shown here with the orange wire.

7 The Code sudo nano LED.py Type in the following code:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(18,GPIO.OUT) while True: print "LED on" GPIO.output(18,GPIO.HIGH) time.sleep(1) print "LED off" GPIO.output(18,GPIO.LOW) time.sleep(1) Once you have typed all the code and checked it, save and exit the text editor with “Ctrl + x” then “y” then “enter”. Running the Code To run this code type: sudo python LED.py You will see the LED turn on for a second and then turn off. If your code does not run and an error is reported, edit the code again using sudo nano LED.py.

8 Controlling LED via Localhost
First install Apache HTTP server and its PHP extension by: sudo apt-get install apache2 php5 libapache2-mod-php5 Navigate to the browser and type your Pi's IP address. You will see an “It Works” page. Now we should test whether its PHP extension is working.  To test, go to /var/www/html directory (cd /var/www/html) then delete the filename index.html and create a file index.php Then type the php code below : phpinfo(); Save it and refresh the page in your browser. A phpinfo will appear.Thus the PHP extension is installed properly. If any of the pages do not appear try reinstalling apache server and its PHP extension.

9 PHP and HTML HTML stands for Hyper Text Markup Language. It is the standard markup language for creating Web pages. PHP is an HTML-embedded server side scripting language. Its goal is to allow web developers to write dynamically generated pages quickly PHP is designed to interact with HTML and PHP scripts can be included in HTML page without a problem. In an HTML page, PHP code is enclosed within special PHP tags which is <?php ?>

10 CODE Go back to your file index.php using the terminal and replace the code below:

11 Once you have typed all the code and checked it, save and exit the text editor with “Ctrl + x” then “y” then “enter”. IP Address

12 RGB LED

13 7 Color flash

14 Laser Module


Download ppt "WORKSHOP LED CONTROL."

Similar presentations


Ads by Google