A Microcontroller Discussion Board
September 09, 2010, 04:32:37 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: You may have to register before you can post: click the register link below to proceed.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SIMPLE CODING USING PIC16F84 -LED BLINKING AND RUNNING LIGHT  (Read 788 times)
0 Members and 1 Guest are viewing this topic.
king_diaw
Freshy
*
Posts: 11


View Profile
« on: April 10, 2008, 06:00:39 AM »


HAI, THIS IS BASIC PROGRAMMING actually that use one input from push button and seven output (LED's)

if somebody interesting you can copy this program and assembler using MPLAB.

;----------------------------------------------------
;PROGARMMER:KING DIAW
;TASK:SET PORTA,1 AND PORTB,0~7 AS OUTPUT
;IN NORMAL CONDITION (INPUT=0) OUTPUT ACT LIKE RUNNING LIGHT
;WHEN PUSH BUTTON PRESSED (INPUT=1) OUTPUT BECOME BLIKING
;----------------------------------------------------
    list p=16f84

PORTA      EQU       5
PORTB      EQU       6
countlow      EQU        H'10'
counthigh     EQU          H'11'

      ORG      0h
      goto      start
DELAY
      movlw       H'FF'
      movwf      countlow
      movlw       H'FF'
      movwf      counthigh
;*************************************************
;SUBROUTINE DELAY
delayloop               
      decfsz       countlow      
      goto       delayloop   
      decfsz      counthigh   
      goto      delayloop   
      return
;************************************************

;************************************************
;INTIALIZE I/O

start   
      clrf       PORTB
      movlw       B'00000000'
      tris       PORTB
      movlw       B'00011111'
      tris       PORTA
      clrf      PORTB
;************************************************      
;************************************************
;MAIN PROGRAM

loop         btfss       PORTA,1
          goto      rotate

blink          movlw      b'01010101'
           movwf      PORTB
      call      DELAY
      movlw      b'10101010'
      movwf      PORTB
      call       DELAY
      goto      loop
rotate         clrf      PORTB
      bsf         PORTB,0
left          call      DELAY
                  rlf       PORTB
      btfss       PORTB,7
      goto        left
right            call      DELAY
                  rrf       PORTB
      btfss      PORTB,0
      goto      right
      goto      loop   
;**********************************************
end
Logged
A Microcontroller Discussion Board
« on: April 10, 2008, 06:00:39 AM »

 Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
PIC16F84 Microcontroller Tutorial PIC mcuprogrammer 2 2679 Last post April 08, 2008, 04:41:41 AM
by king_diaw
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!