Newbie to pic but not electronics


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    shouldnt it be something like this?

    Code:
    Button var PORTB.0		' Push button
    LED1 var PORTB.1                           ' Led 1
    LED2 var PORB.2                             ' Led 2 
    
    
    	If Button=1 Then	             ' If button is push
    		High LED1	' Turn on the LED
    IF Button=0 Then
               High LED2	
    endif

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You have two IF's but only one ENDIF, so that would error...

    Try this... which includes a few additional things to think about....

    Code:
    	ButtonA var PORTB.0
    	LED1 var PORTB.1
    	LED2 var PORTB.2
    
    	TRISB=%00000001
    
    Loop:
    	If ButtonA=1 then
    		High LED1
    		LOW LED2
    		else
    		LOW LED1
    		HIGH LED2
    		endif
    	Goto Loop
    
    	End
    Finally, check your PBP manual - BUTTON is a reserved word, you can't use it as a variable.

Similar Threads

  1. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. PIC to PC newbie
    By Michael in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 19th June 2007, 01:07
  4. PIC Newbie
    By azmax100 in forum Schematics
    Replies: 7
    Last Post: - 23rd February 2007, 04:52
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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