Reply to topic  [ 1 post ] 
Flash LEDs - PIC Development Board + PIC16F877A 
Author Message

Joined: Fri Aug 01, 2014 9:17 am
Posts: 20
Post Flash LEDs - PIC Development Board + PIC16F877A
This demonstration uses the PIC - PIC Development Board + PIC16F877A (HCDVBD0003) to flash the LEDs.

No additional components are required simply ensure the LED (j3 /LED - EN) link is in place.

    This demo flashes the LEDS in sequence.
    This code can be easily be adapted for other 40 pin Microchip devices, simply change the #chip type
    This code uses the external resonator, however, the #config can be removed to use the internal oscillator

'   FILE:    PIC_16F877a_LED_Rotate_Test.gcb
'   DATE:    02/08/14
'   VERSION: 0.1a
'   AUTHOR:  Anobium

'  This test program will flash the LEDs connected to port D on the development board, aka Knight Rider.. back and forth LEDs
'  It was written using the Great Cow Basic (GCB) complier. Install GCB - you are recommended to use
'  GCB@SYN from the Great Cow Basic website.

'    This code is free software; you can redistribute it and/or
'    modify it under the terms of the GNU Lesser General Public
'    License as published by the Free Software Foundation; either
'    version 2.1 of the License, or (at your option) any later version.

'    This code is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    Lesser General Public License for more details.

'    If you require a copy of the GNU Lesser General Public
'    License along with this code; please write to the Free Software
'    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
' Chip settings
#chip 16F877a, 4          ' Select the chip and the chip speed
#config Osc = XT          ' Select the external oscillator

' Set ports
  dir portd out            ' Set the portd as outputs
  set portd = 255        ' Set the initial value of the state of the LEDs

' Set required variables
  ddelay = 125          ' Set the delay for the LEDs

  do forever                      ' Loop forever

    repeat 8                      ' Repeat this loop 8 times
           Rotate PORTD Left      ' Rotate the portD to the left, shifting Carry Bit (equals 0 to first port)
           wait ddelay ms         ' wait

    end Repeat                    ' Loop
    wait ddelay ms

    repeat 7                      ' Repeat this loop 7 times, 7 prevents a double flash of one of the LEDs
         Rotate PORTD Right       ' Rotate the portD to the right.
         wait ddelay ms           ' wait
    end Repeat                    ' loop

    set portd = 255               ' reinitialise the port
    Set C off                     ' ensure the Carry Bit is 0

  loop                            ' loop forever

You do not have the required permissions to view the files attached to this post.

Thu Aug 14, 2014 11:10 am
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to &
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD