NOOB in need of help


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    14


    Did you find this post helpful? Yes | No

    Red face

    Sounds good.

    How do you make it do one thing when the button is pressed and another when it is not? Like while pressed make a motor run and then stop when not pressed without it being a seprate button?

    Thanks for the help

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    main:
    
    Pause 200
    
    if portb.0 = 1 then gosub pressed0
    
    if portb.1 = 1 then gosub pressed1
    
    if portb.2 = 1 then gosub pressed2
    
    if portb.3 = 1 then gosub pressed3
    
    goto main
    
    pressed0:
    toggle portb.4
    return
    
    pressed1:
    toggle portb.5
    return
    
    pressed2:
    toggle portb.6
    return
    
    pressed3:
    toggle portb.7
    return
    
    end
    Try this way it should do what you need.

    See TOGGLE command on manual.

    Al.
    Last edited by aratti; - 25th January 2009 at 00:53.
    All progress began with an idea

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by studysession View Post
    Sounds good.

    How do you make it do one thing when the button is pressed and another when it is not? Like while pressed make a motor run and then stop when not pressed without it being a seprate button?

    Thanks for the help
    Your posted code should do that.???
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Dave, let him discover the Toggle instruction.

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Dave, let him discover the Toggle instruction.

    Al.
    Okie Doki
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2009
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    The toggle wasn't waht I was looking for. I did try it. When you hold down the button and the toggle was going - on/off/on/off etc.....

    Thanks for all the help. I am sure I will be posting more questions as I move forward.

    Thanks again -
    Keith

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Sec.5.36

    Hi Keith,
    Looks like a classic IF THEN ELSE to me.
    Code:
    TRISB = %00001111    ' 4 upper as outputs 4 lower as inputs
    IF  PortB.0 = 1 THEN ' if true then goto next statement
    PortB.4 = 1          ' turn on this port 
    ELSE                 ' goes to here if false
    PortB.4 = 0          ' Turns this port off
    ENDIF                ' ends the if then test for true / false and allows code to continue
    make sure to use resistors pulling down if you close switches to activate or pulling up if you open switches to activate.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Not sure at all but...
    Code:
            TRISB=%00001111
            PORTB=0
    
    Loop:
            PORTB=(PORTB<<4)
            PAUSE 200
            GOTO Loop
    Steve

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

Similar Threads

  1. LCD_AnyPin.pbp
    By Darrel Taylor in forum PBP Extensions
    Replies: 112
    Last Post: - 23rd September 2024, 18:06
  2. Replies: 2
    Last Post: - 7th March 2008, 02:16
  3. Help a noob out?
    By yasiryassin in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th January 2008, 06:37
  4. Crystals & Caps - Super noob question??
    By kevj in forum General
    Replies: 4
    Last Post: - 24th September 2007, 17:11
  5. Uber noob needs clarity!
    By bill12780 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd July 2007, 21:40

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