Need help with RC car code


Closed Thread
Results 1 to 6 of 6
  1. #1
    rey1867's Avatar
    rey1867 Guest

    Question Need help with RC car code

    Before I start, Id just like to clarify that the only programming experience I have had is with VB. As such, I found picbasic's programming protocol rather easy. However, I have had no luck in getting my microcontroller to function.

    My plan is :

    1) Whenever the user presses a button on the controller, a signal is sent to any of the inputs which in turn causes an output to pulse.

    2) The pulses for movement differ and are transmitted to the car using an infrared transmitter.

    3) When they reach the car, these pulses are decoded and the proper output becomes active high and the car runs in the proper direction.

    Im sorry if Im asking a bit too much, but I really need this to get to work as my project is due by friday.

    thx

    '************************************************* *****************************
    'This is the code for the transmitter in the remote
    Device = 16F84A

    XTAL = 4 'Dont know clock frequency

    Input PortA

    Output PortB

    If PortA.2 = 1 Then 'RA2 is input, Forward
    PulsOut PortB.7 , 50 'RB7 = output, Pulse = 0.5 ms long

    ElseIf PortA.3 = 1 Then 'RA3 is input, Reverse
    PulsOut PortB.6, 100 'RB6 = output, Pulse = 100 ms long

    ElseIf PortA.1 = 1 Then 'RA1 is input, Right
    PulsOut PortB.5, 150 'RB5 = output, Pulse = 150 ms long

    ElseIf PortA.0 = 1 Then 'RA0 is input, Left
    PulsOut PortB.4, 200 'RB4 = output, Pulse = 200 ms long

    End If

    '************************************************* *****************************

    '************************************************* *****************************
    'This is the code for the reciever in the car

    Device = 16F84A

    XTAL = 4

    Input PortA

    Output PortB

    Dim Move as Byte

    Loop:

    Move = PulsIn PortA.2, 1 'RA2 = input

    If Move = 200 Then 'Left
    PortB.7 = 1 'RB7 = output

    ElseIf Move = 150 Then 'Right
    PortB.6 = 1 'RB6 = output

    ElseIf Move = 100 Then 'Reverse
    PortB.5 = 1 'RB5 = output

    ElseIf Move = 50 Then 'Forward
    PortB.4 = 1 'RB4 = output
    End If

    GoTo Loop

    '************************************************* *****************************

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


    Did you find this post helpful? Yes | No

    Default

    Your code appears to contain non PICBasic statements. Are you using MeLabs PICBasic Pro Compiler? If not, you've landed in the wrong forum.

    Looks like the Academic year end is fast approaching... and Beer and Girls in excess during the early semester means projects just ain't finished...

  3. #3
    rey1867's Avatar
    rey1867 Guest


    Did you find this post helpful? Yes | No

    Default

    thx for your speedy reply melanie

    I am pretty sure I am using the correct compiler, but just to check I have uploaded an image.


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


    Did you find this post helpful? Yes | No

    Default

    Miiiip! you're not on the right forum, Here it's Melabs PicBasic... Not PROTON PicBasic.

    You have to go at www.picbasic.org/forum
    Steve

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

  5. #5
    rey1867's Avatar
    rey1867 Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Miiiip! you're not on the right forum, Here it's Melabs PicBasic... Not PROTON PicBasic.

    You have to go at www.picbasic.org/forum
    my apologies

    thank you for directing me to the correct forum

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


    Did you find this post helpful? Yes | No

    Default

    My pleasure Sir!
    Steve

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

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Remote Car Starter Safety
    By CocaColaKid in forum General
    Replies: 8
    Last Post: - 22nd November 2005, 09: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