A simple IF Statement!!!!


Results 1 to 26 of 26

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    here's the one who'll work...
    Code:
    CMCON=7 'disable analog comparator
    
    'Set pin direction
    
    TRISA = %11111111
    TRISB = %00000000
    
    'Set pgm vars and cons
    
    SW1 var porta.0
    LED var portb.0
    
    'start the program
    
    start:
    if SW1 = 1 then 
         LED =1 'can also use High LED
         pause 500 'or whatever delay you want
         LED=0 'can also use LOW LED
    endif
    
    'or if you want to give LED output the same status as SW1
    'you can use the following line
    '
    '
    'while SW1
    '     LED=1
    'wend
    'LED=0
    '
    '
    '
    'or with IF THEN 
    '
    'If SW1 then LED=1
    'IF SW1=0 Then LED=0
    '
    'Select CASE version
    '
    'Select Case SW1
    '     Case 0
    '          LED=0
    '     Case 1
    '          LED=1
    'End Select
    '
    
    
    
    goto start
    end
    Last edited by mister_e; - 6th December 2004 at 23:48.
    Steve

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

Similar Threads

  1. Simple Blinking LED - WTF!!
    By johnnylynx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2010, 06:19
  2. Simple LCD code not working!...WHY?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th November 2009, 19:48
  3. 16F883 and Problems with HIGH statement
    By aaanekre in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th October 2009, 01:09
  4. END Statement
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th November 2008, 14:48
  5. getting around the basic IF - THEN statement
    By dw_pic in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th February 2006, 14:10

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