Updated 24 September 2020

Kits and Gadgets Electronics Inc.
Farwaniya, Kuwait 80003
Kuwait

ph: +965 99571844

kits@kits-gadgets.com

  • Electronic Kits
  • Parts on Sale
  • Parts in StockClick to open the Parts in Stock menu
    • Resistor
    • Potentiometer
    • Capacitor
    • Trimmer Capacitor
    • Transistor
    • Crystal
    • Diode
    • LED
    • Diac
    • Thyristor
    • IC Socket
    • IC - Logic
    • IC - Linear
    • IC - Op-Amp
    • IC - VLSI
    • Relay
    • Motor
    • Lamp
    • Transducer
    • Gear
    • Switch
    • Heatsink
    • Parts Store Inventory
  • Brand New Items
  • Used Items
  • Power Supply
  • Raspberry Pi VaultClick to open the Raspberry Pi Vault menu
    • Demonstration Kit
    • Demonstration Kit - R3
    • The P1 Header Guide
    • BBC BASIC Tutorials
    • Activating the GPIO
    • LED Program
    • Motor Program
    • Solenoid Program
    • Stepper Motor
    • 8 Relay Program
    • GPIO as Input
    • Motors and Sensors Connection Diagram
    • Autonomous Program
    • Infrared Sensor
    • Ultrasonic Sensor
    • Camera Controller
    • PWM Program
    • Robotic Arm
    • STRYDER Robot
    • Demo Kit Program
  • Arduino VaultClick to open the Arduino Vault menu
    • Stepper Motor w/ LED
    • DCMotor
  • NodeMCU ProjectsClick to open the NodeMCU Projects menu
    • Running 8 LEDs
    • 8 LEDs and ULN2803
    • 8 LED Active Modes
    • ON-OFF Switch
    • Switch, Relay and LEDs
    • Motor Drive Interface
    • Connecting to Wi-Fi
    • IR Sensor
  • More GPIOsClick to open the More GPIOs menu
    • Accessing the P5 GPIOs
  • Prototypes
  • Computer Parts
  • Picture GalleryClick to open the Picture Gallery menu
    • Other Prototypes
    • Revived HP Laptop
    • Dismantled Helicopter
    • Dismantled Phone
    • ACER Laptop Repair
    • Revived Laptop
    • Inside of Electric Drill
    • Video Cam Automation
    • My Tours and Travels
  • My Original DesignClick to open the My Original Design menu
    • Handycam Automation
    • Autonomous Robot
  • What's New!Click to open the What's New! menu
    • Article-1
    • Article-2
    • Article-3
    • Article-4
    • Article-5
    • Article-6
    • Article-7
    • Article-8
    • Article-9
    • Article-10
    • Article-11
    • Article-12
    • Article-13
    • Article-14
    • Article-15
    • Article-16
    • Article-17
    • Article-18
    • Article-19
    • Article-20
    • Article-21
    • Article-22
    • Article-23
    • Article-24
    • Article-25
    • Article-26
    • Article-27
    • Article-28
    • Article-29
    • Article-30
    • Article-31
  • Forum
  • Video GalleryClick to open the Video Gallery menu
    • IR Proximity Sensor
    • Robot Vacuum Cleaner
    • Robotic Arm - RPi
    • Raspberry Pi Demo Kit
  • About Us
  • Contact Us

LED Program

DRIVING AN LEDs

The Light Emitting Diodes (LEtD) is considered one of the most versatile electronic components ever invented. This is the reason why its continued development surpassed many components in electronics. Nowadays, LEDs comes in various sizes, shapes, colors, luminosity, intensity, configuration, frequency, packaging and above all its current consumption.

LEDs are ideal for testing Raspberry Pi GPIO ports, it is safe to use because it consumes very less current that the RPI GPIO port can safely sink. LEDs that operates below 3mA at 1.5 Volts are now available and in different colors.

To test or monitor the output of each GPIO port, you need to connect atleast  3 Kilohms or 1 Kilohms (to be safe)  resistor in series with the LED. You can reduce the resistor value afterwards if you are not satisfied with the brightness but calculation maybe needed to be precise and prevent damaging the LED or the RPI itself. For high voltage/high current LEDs, you can use the ULN2003, ULN2004 or ULN2803 IC, transistor or through a relay to drive those type of LEDs. 

 

LED TO RASPBERRY PI CONNECTION

  

 

  

THE PROGRAM

    

   10 REM To demonstrate relays, LEDs, motor and solenoid activation.
   20 REM Program for Raspberry Pi Demonstration Test Kit
   30 REM Programmed by: Rolly Estomaguio
   40 REM Created on: 12 May 2014
   50 REM http://www.kits-gadgets.com
   60 ON ERROR PRINT REPORT$;" at line ";ERL:END
   70 PROCinit
   80 PRINT "Press Escape to finish"
   90   FOR Loop% = 1 TO 4
  100   FOR J% = 0 TO 8
  110  REM GOTO 690: REM THIS JUMP IS TO WAIT FOR 'S' KEY BEING PRESSED.
  120 REM  FOR J% = 0 TO 8 : FOR Loop% = 1 TO 4
  130  SYS "GPIO_WriteData",A%(J%),1
  140   NEXT
  150   TIME=0:REPEAT UNTIL TIME > 50
  160   FOR J% = 0 TO 8
  170     SYS "GPIO_WriteData",A%(J%),0
  180   NEXT
  190   TIME=0: REPEAT UNTIL TIME >30
  200 NEXT
  210 FOR I%=1 TO 4
  220   FOR J%= 0 TO 8
  230     SYS "GPIO_WriteData",A%(J%),1
  240  TIME=0:REPEAT UNTIL TIME>5
  250     SYS"GPIO_WriteData",A%(J%),0
  260   NEXT
  270 NEXT
  280 FOR J%= 8 TO 0 STEP-1
  290     SYS "GPIO_WriteData",A%(J%),1
  300     TIME=0:REPEAT UNTIL TIME>5
  310    SYS"GPIO_WriteData",A%(J%),0
  320   NEXT
  330 FOR I%=1 TO 4
  340 FOR J%= 0 TO 8
  350   SYS "GPIO_WriteData",A%(J%),1
  360     TIME=0:REPEAT UNTIL TIME>1
  370     SYS"GPIO_WriteData",A%(J%),0
  380   NEXT
  390 NEXT
  400   FOR J%= 8 TO 0 STEP-1
  410     SYS "GPIO_WriteData",A%(J%),1
  420     TIME=0:REPEAT UNTIL TIME>1
  430     SYS"GPIO_WriteData",A%(J%),0
  440   NEXT
  450   FOR J%= 0 TO 8
  460     SYS "GPIO_WriteData",A%(J%),1
  470     FOR T%=1 TO 100000:NEXT
  480     SYS"GPIO_WriteData",A%(J%),0
  490   NEXT
  500   FOR J%= 8 TO 0 STEP-1
  510     SYS "GPIO_WriteData",A%(J%),1
  520     FOR T%=1 TO 100000:NEXT
  530     SYS"GPIO_WriteData",A%(J%),0
  540   NEXT
  550 GOTO 690
  560 DEFPROCinit
  570 OSCLI"RMEnsure GPIO 0.00 RMLoad GPIO"
  580 OSCLI"RMensure GPIO 0.40 ERROR Please install the GPIO module"
  590 SYS"GPIO_EnableI2C",0
  600 SYS"GPIO_ExpAsGPIO",2
  610 SYS"GPIO_GetBoard" TO PiType%
  620 DIM A%(30)
  630 IF PiType%=12 A%()= 3,4,17,27,22,10,9,11,7
  640 REM OTHER GPIOs NOT ACTIVATED: 2,18,8,24,23,15,14,25
  650  ENDPROC
  660 REPEAT
  670 REM FOR X% = 1 TO 8
  680 REM INPUT 1,2,3,4,10,11,12,13 FOR 8 LEDSs
  690 L$= GET$: OFF
  700 IF L$= "1" THEN N% = 1
  710 IF L$= "2" THEN N% = 2
  720 IF L$= "3" THEN N% = 3
  730 IF L$= "4" THEN N% = 4
  740 IF L$= "5" THEN N% = 5
  750 IF L$= "6" THEN N% = 6
  760 IF L$= "7" THEN N% = 7
  770 IF L$= "8" THEN N% = 8
  780 IF L$= "R" OR L$= "r" THEN PROC_rightmov
  790 IF L$= "L" OR L$= "l" THEN PROC_leftmov
  800 IF L$= "O" OR L$= "o" THEN PROC_off_led
  810 IF L$= "Q" OR L$= "q" THEN QUIT
  820 IF L$= "S" OR L$= "s" THEN RUN
  830
  840 SYS "GPIO_WriteData",A%(N%),1
  850 GOTO 690
  860 DEFPROC_off_led
  870 FOR E%= 1 TO 17
  880 SYS "GPIO_WriteData",A%(E%),0
  890  NEXT
  900 GOTO 690
  910 DEFPROC_rightmov
  920 FOR R%= 1 TO 17
  930 SYS "GPIO_WriteData",A%(R%),1
  940 FOR D%= 1 TO 1000000: NEXT
  950 NEXT
  960 GOTO 690
  970 DEFPROC_leftmov
  980 FOR L%= 8 TO 1 STEP -1
  990 SYS "GPIO_WriteData",A%(L%),1
 1000 FOR D%= 1 TO 1000000: NEXT
 1010 NEXT
 1020 GOTO 690

Copyright 2013 Kits and Gadgets Electronics Inc. All rights reserved.

Web Hosting by Yahoo

Kits and Gadgets Electronics Inc.
Farwaniya, Kuwait 80003
Kuwait

ph: +965 99571844

kits@kits-gadgets.com