POT command


Closed Thread
Results 1 to 2 of 2

Thread: POT command

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    Garden Grove, Ca
    Posts
    5

    Default POT command

    Hi, all
    I am new to the forum and terrible at coding.

    I am doing a project that reguires 4 sensors.
    I have named them sens1 thru sens4.
    I read the sensors and send the serial data to an lcd.

    Include "modedefs.bas"

    trisa = %00000010
    trisb = %00001111

    lcd var PORTA.0 ' Lcd connected porta.0
    sens1 var PORTB.0 ' Light sensor 1 connected to portb.0
    sens2 var PORTB.1 ' Light sensor 2 connected to portb.1
    sens3 var PORTB.2 ' Light sensor 3 connected to portb.2
    sens4 var PORTB.3 ' Light sensor 4 connected to portb.3
    cw_az var PORTB.4 ' To turn azimuth motor clockwise
    ccw_az var PORTB.5 ' To turn azimuth motor counterclockwise
    cw_el var PORTB.6 ' To turn elevation motor clockwise
    ccw_el var PORTB.7 ' To turn elevation motor counterclockwise
    b0 var byte ' Place to hold variable value
    b1 var byte ' Place to hold variable value
    b2 var byte ' Place to hold variable value

    'Routine to display values. THESE IS WHAT I AM TRYING TO IMPROVE

    sens_chk: 'Check light sensors
    pot sens1,255,B0 'Check sensor 1. Put value in B0
    serout lcd,N2400, [254,1] 'Clear lcd
    serout lcd,N2400, ["sensor1",#B0] 'Send sensor 1 value to lcd
    pause 1000 'Delay 1 second

    pot sens2,255,B0 'Check sensor 2. Put value in B0
    serout lcd,N2400, [254,1] 'Clear lcd
    serout lcd,N2400, ["sensor2",#B0] 'Send sensor 2 value to lcd
    pause 1000 'Delay 1 second

    pot sens3,255,B0 'Check sensor 3. Put value in B0
    serout lcd,N2400, [254,1] 'Clear lcd
    serout lcd,N2400, ["sensor3",#B0] 'Send sensor 3 value to lcd
    pause 1000 'Delay 1 second

    pot sens4,255,B0 'Check sensor 4. Put value in B0
    serout lcd,N2400, [254,1] 'Clear lcd
    serout lcd,N2400, ["sensor4",#B0] 'Send sensor 4 value to lcd
    pause 1000 'Delay 1 second
    goto start

    end

    Is there a way to eliminate repeating the serial out commands?
    Can it be done with a FOR..NEXT loop?

    I will greatly appreciate any help.

    Joe

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Joe,

    This addition/substitution compiles okay but I have not tried on an actual chip. Let us know.

    X var byte

    For X = 0 to 3
    pot portb.0[X],255,B0
    serout lcd,N2400, [254,1]
    serout lcd,N2400, ["sensor",#X,#B0]
    pause 1000
    Next X

    (You also do not have Start: defined for the goto Start line of your program)

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

Similar Threads

  1. Using the Pot command.
    By timseven in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th August 2009, 20:23
  2. PBP2.50b and POT command problem ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th October 2008, 17:14
  3. Replies: 4
    Last Post: - 24th January 2007, 22:20
  4. pot command
    By lerameur in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 25th November 2006, 04:12
  5. Can I do this???
    By noobie in forum mel PIC BASIC
    Replies: 2
    Last Post: - 10th June 2006, 18:57

Members who have read this thread : 0

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