input command (newbie question)


Closed Thread
Results 1 to 3 of 3
  1. #1
    kctan's Avatar
    kctan Guest

    Default input command (newbie question)

    i am new and i write the input code in microcode studio plus like this
    i using PIC16F877A

    define osc 20
    trisa = %111111
    trisb = %00000000
    x var byte
    start:
    if porta.0 = 1 then
    portb.0 = 1
    else
    portb = %00000000
    endif
    when i simulate in proteus 6, i got nothing at output LED
    when i was pressed a switch in proteus, it got signal go in and the voltage is 5.33 after when at open switch i find that porta.0 pin still got voltage that is 3.44 wat is the problem
    wat's wrong with my coding?

    define osc 20
    trisa = %111111
    trisb = %00000000
    x var byte
    start:
    x=0
    while porta.0 =1 and x = 10
    portb.0 = 1
    x=x+1
    wend
    with this code i'am also cannot work so wat is my problem in input?
    does my program write wrong?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi kctan,

    Nothing wrong with the first example. Except there's no GOTO at the end to form a loop. (but you probably just missed it with the cut&paste) You might want to try it on a real chip, instead of a simulator.

    However, in the second example.
    Code:
    x=0
    while porta.0 =1 and x = 10
        portb.0 = 1
        x=x+1
    wend
    The "while" will never execute, because x = 10 will never be True.

    Also, the code shown would be for PicBasic Pro, Plain PicBasic doesn't have a "while" command.
    Last edited by Darrel Taylor; - 24th November 2005 at 00:02.
    DT

  3. #3
    kctan's Avatar
    kctan Guest


    Did you find this post helpful? Yes | No

    Talking thanks you

    thanks you

Similar Threads

  1. Question from New member A/D input 16f876
    By mbruno in forum General
    Replies: 2
    Last Post: - 26th January 2008, 14:52
  2. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 15:44
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. PIC16F628A input question
    By yankee in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th January 2006, 03:35
  5. ER Clock input question
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th May 2004, 10:10

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