serial to PIC


Closed Thread
Results 1 to 23 of 23

Thread: serial to PIC

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    So So but I can't find the answer on it

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


    Did you find this post helpful? Yes | No

    Default Tesla

    I misread your post before...
    Code:
     SERIN PORT?.?,N9600,[K],myVar
    IF myVar = 3 THEN gosomeplace or dosomething
    Send K and another value from the PC " K3 " for example.
    The PIC will wait for the "K". When the PIC receives a "K" the next character will be written to myVar.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2009
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Hi..
    thank u alot I lik [Always wear safety glasses while programming]

    I forget to tell u I am new in PICBASIC PRO now only 2 weeks. I think the code will be like this:
    define osc 4
    include "bs2defs.bas"

    wait:
    SERIN PORTa.1,N9600,["K3"],myVar
    IF myVar = 3 THEN out

    out:
    HIGH PORTb.7
    PAUSE 300
    LOW PORTb.7
    goto wait

    but I cant understand [myvar]. How I can decide it???
    Thank u in advance.

  4. #4
    Join Date
    Jul 2009
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    its not working

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    define osc 4
    include "bs2defs.bas"
    
    wait:
    
    SERIN PORTa.1,N9600,["K"],myVar
    
    IF myVar = 51 THEN out ' Ascii 51 = decimal 3 (When you type 3 myvar will be 51)
    
    goto Wait ' this line is esential otherwise any key will activate the function 
    
    out:
    
    HIGH PORTb.7
    
    PAUSE 300
    
    LOW PORTb.7
    
    goto wait

    This is the code that Dave suggested.

    From keyboard type K3 to activate portB.7 for 300 millisecs.


    Al.
    Last edited by aratti; - 11th July 2009 at 16:35.
    All progress began with an idea

  6. #6
    Join Date
    Jul 2009
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Now I am using windows hyper terminal to send serial signal. When I am sending [k] from it the terminal send it in ascii or in hex??
    I think send it in Ascii!!!

    so I have to send [k] or [k3]??

    and becuse I am new in PICBASIC PRO I can't understand how I can decide [myvar]
    Can u help ??

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


    Did you find this post helpful? Yes | No

    Default

    Read the post from Al very carefully. He has everything there you need.

    Not sure what you mean by deciding "myVar". It is just a variable
    to store a value. The serin command will write data to that
    variable and the if/then part checks to see what the value is.

    Oh, the safety glasses thing. It is not a joke.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  2. Automatic VB6 to pic serial connection
    By arniepj in forum Code Examples
    Replies: 13
    Last Post: - 10th January 2008, 07:57
  3. Serial Com Pic to Pic
    By uludere72 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st May 2005, 10:06
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

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