PicBasicPro Code help!


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    19

    Smile PicBasicPro Code help!

    Hi!

    I'm new to PIC programming....I have done projects with Basic Stamp 2...

    Two codes question;

    With a ex VAR WORD (ex=2343). How do I get the digit 2 with picbasic pro?
    With basicstamp it's NIB 3. (starting from the right from 0).

    Other question;

    I have a 40 pin PIC (16f877) and wanna get PORTB (rb0,rb1,rb2 and rb3) to output and ascii number all together.How do I do it with picbasic pro?

    With basic stamp here is te code, LOW and HIGH port can be used.

    LEDs VAR OUTD ' LEDs on P12 - P15
    LEDsDirs VAR DIRD ' DIRS control for LEDs
    display VAR OUTC ' Transistors on P8 - P11
    cntdisplay VAR DIRC ' DIRS control for Transistors

    LEDs = 2 (pin 12 t0 15 will output 2)


    Tank you....(don't forget beginner) ...

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Salut Michel,
    NIB 3 should be DIG 3 in PBP, refer to section 4.17.7 of your manual

    PORTB (rb0,rb1,rb2 and rb3) to output and ascii number all together.
    TRISB=0 ' all PORTB i/o = output
    '
    '
    '
    '
    PORTB=YourVariable ' use with care

    Refer to section 10 for PIcBasic VS Stamp difference.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Hi mister_e!

    Tanks for the first question....

    But the second....portB has 8 pins rb0 to rb7 and I have to define the 4 pins (0 to 3) only to use for output my number. I have, imagine to dfive one variable with those 4 pins and than ....

    Can i say ex = portB.low...let's say! and than ex = 2

    Thanks again!

  4. #4
    Join Date
    May 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Finaly got it!

    Made my protoboard and finaly found the code for assinging port pins.





    DEFINE OSC 4

    TRISB = %00000000

    x var byte
    Leds var byte
    Digs var byte

    ENABLE DEBUG

    main:


    for x = 0 to 9
    leds = x
    Digs = x
    GOSUB PORTSsegments
    gosub PORTSdiggits
    Pause 500 ' Delay for .5 seconds
    leds = %0000
    Digs = %0000
    GOSUB PORTSsegments
    gosub PORTSdiggits
    Pause 500 ' Delay for .5 seconds
    next x
    Goto main ' Go back to loop and blink LED forever


    PORTSsegments:

    PortB.0 = leds.0 : PortB.1 = leds.1 : PortB.2 = leds.2 : PortB.3 = leds.3

    return

    PORTSdiggits:

    PortB.4 = Digs.0 : PortB.5 = Digs.1 : PortB.6 = Digs.2 : PortB.7 = Digs.3

    return

    DISABLE DEBUG

    End
    Attached Images Attached Images  

Similar Threads

  1. Nokia COLOR LCD PicBasicPro 2.50a example code
    By skimask in forum Code Examples
    Replies: 49
    Last Post: - 28th September 2011, 01:43
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts