PCB Heaven

General Category => Your projects => Topic started by: Automan on December 22, 2013, 22:10:06 PM

Title: Simultaneous leds
Post by: Automan on December 22, 2013, 22:10:06 PM
Hi guys i am new to this forum,but have a lot of questions as i am new to this subject

i was just thinking could tell me the code either in C or assembly to blink 3 leds simultaneously together for a pic 16f88 chip,its my first

chip ,so be gentle hahahaha, thanks in advance
Title: Re: Simultaneous leds
Post by: _pike on December 23, 2013, 00:46:21 AM
Hello automan and welcome to the forum.
Are you interested of learning microcontroller programming or you just want someone to make a code for you and make a circuit to work? If you you like to learn why don't you take a look here http://www.pcbheaven.com/picpages/ and we are here to help you out.....

Regards Panagiotis
Title: Re: Simultaneous leds
Post by: Automan on December 23, 2013, 04:28:38 AM
i would like to learn and make circuits ,how ever i went through the tutorials ,and they were very helpful in fact my LED sequencer project worked but i want a small modification ,and light up 3 to 7 LEDS simulataneously with a blinkrate of about 500msec ,i cant seem to write the code for pic 16f88 i have tried ,

if you can help me out i would be very grateful,thanks in advance
Title: Re: Simultaneous leds
Post by: kam on December 23, 2013, 07:20:59 AM
what you wanna do is start with the very simple. You have to be able to blink one led first. Can you do this? i mean not by going through a tutorial, but writing the code yourself.
Title: Re: Simultaneous leds
Post by: Automan on December 23, 2013, 12:33:00 PM
No i cant write code on my own ,but with the help of the tutorial i was able to do this ,now i am looking to blink more than one led simultaneously
Title: Re: Simultaneous leds
Post by: Automan on December 23, 2013, 13:07:39 PM
hi i was able to blink more than one led on my own i was able to re engineer the code to do this
Title: Re: Simultaneous leds
Post by: Automan on December 23, 2013, 14:11:08 PM
here s the code it blinks two leds together and the third one is permanently on,i would like to blink seven leds simultaneously can you give me the code statement that does this ,here is the my current code:


 list       F=inhx8m, P=16F88, R=hex, N=0
#include  P16F88.inc; PIC definitions
 __config _config1,_INTRC_IO & _WDT_OFF & _LVP_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _CCP1_RB0 & _CP_OFF
 __config _config2,_IESO_OFF & _FCMEN_OFF
 Errorlevel -302      ; switches off Message [302]: Register in operand not in bank 0.
; Definitions -------------------------------------------------------------

; RAM preserved -----------------------------------------------------------
   cblock 0x20
      WaitCounter,WaitCounter2
   endc
; Conastants --------------------------------------------------------------

; Program Memory ----------------------------------------------------------
                org     0
                goto    Init
; Interrupt Service Routine -----------------------------------------------
                org     4               ; ISR beginning
; -------------------------------------------------------------------------
; Microcontroller initialization
Init           
            include Init_normal.inc   ;Include the PIC Initialization routine


;##########################################################################
; Main Program ------------------------------------------------------------

Start
            bank1               ;Go to bank 1
            movlw b'11111111'      ;
            movwf TRISA            ;Set the port pin types of the RA

            movlw b'11100000'      ;
            movwf TRISB            ;Set the port pin types of the RB
            bank0               ;Go to bank 0

MainLoop
            call Wait250mSec
            call Wait250mSec
            bsf PORTB,0            ;Set RB0 output
         
                bsf PORTB,f
               
       
                call Wait250mSec
            call Wait250mSec
         
                bcf PORTB,0            ;Clear RB0 output
               
                bcf PORTB,f
             
               
               
            goto MainLoop


Wait250mSec     movlw d'250'
            movwf WaitCounter2      ;   

BackWaitLoop2   movlw d'163'         ;
                call WaitWx4Cycles
            movlw d'163'         ;
                call WaitWx4Cycles
            nop
            nop
                decf WaitCounter2,f      ;
                btfss Zero            ;
                goto BackWaitLoop2      ;
                return               ;

WaitWx4Cycles   movwf WaitCounter
BackWaitLoop    decfsz WaitCounter,f
                goto BackWaitLoop
                return


Fins           
                end             ; end of program
Title: Re: Simultaneous leds
Post by: Automan on December 25, 2013, 21:55:56 PM
YO Kam by the way i like your accent  ;)
Title: Re: Simultaneous leds
Post by: kam on December 26, 2013, 12:41:35 PM
YO Kam by the way i like your accent  ;)
hehehe ty!
Title: Re: Simultaneous leds
Post by: _pike on January 03, 2014, 02:11:14 AM
change the below.....

  movlw b'10000000'      ;
  movwf TRISB            ;Set the port

and......

MainLoop

call Wait250mSec
call Wait250mSec

movlw b'111111111'
movwf portb           

call Wait250mSec
call Wait250mSec

movlw b'100000000'
movwf PORTB
               

            goto MainLoop


your leds should be connected from portb0 to portb6...
Title: Re: Simultaneous leds
Post by: Automan on January 04, 2014, 16:52:02 PM
Thanks Pike just came in after a trip ,i will study the code and use it thanks  :)
Title: Re: Simultaneous leds
Post by: Automan on January 06, 2014, 05:53:36 AM
Thanks pike it works perfectly ! 8)
Title: Re: Simultaneous leds
Post by: kam on January 06, 2014, 09:33:56 AM
You make me proud pike!