light sensor program pls help....


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Posts
    7

    Default light sensor program pls help....

    code:

    b0 var byte
    b1 var byte
    b2 var byte

    start:
    LOW 3
    LOW 4
    pot 1, 255,b0 'Read CdS cell # 1
    pot 2, 255,b1 'Read CdS cell # 2
    If b0 = b1 then straight
    if b0 > b1 then left
    if b1 > b0 then right

    straight:
    high 3
    high 4
    goto start

    left:
    b2 = b0 - b1 'Compare numerical values +/15
    if b2 > 15 then left1 'If greater than 15 turn left
    goto straight 'If not go to straight subroutine

    left1: 'Turn left
    high 3
    low 4 'Motor control
    goto start

    right: 'Compare numerical values +/15
    b2 = b1 - b0 'If greater then 15 points
    if b2 > 15 then right1 'Turn toward the right
    goto straight 'If not go straight

    right1: 'Turn right
    high 4
    low 3 'Motor control
    goto start 'Do again

    -------------------

    i used a pic16f84a and xt oscillator. everyone please help me with this program. i try to compile it and it works and program succesfully. but it wont work when i try to build it in the breadboard. please help.

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    it looks like you are controlling the outputs of "3" and "4", but as soon as u tell your program what to set them to, you are restarting the program, and the 1st thing u do is set them both low. So they will only go high for a very very very small amount of time.

    e.g. straight:

    straight:
    high 3
    high 4
    goto start

    start:
    LOW 3
    LOW 4
    ...

    they will only be high for as long as it take the program to goto start.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    That's the same program that you were given in the other thread back in January.
    If it didn't work then, it's probably not going to work now.
    Just because it compiles, assembles, and programs without errors doesn't mean it's going to work the way you want it to work.

    Get rid of the motors, get rid of the neato/nifty stuff.

    Start working from nothing and work your way up.

    How do you know the POT command is actually responding the way you want them to respond?

    In the POT command, you have the 'scale' set at 255. Are you sure this is correct?
    Have you 'calibrated' the 'scale' the way that the PBP manual tells you to set it up?
    How can you be sure that your CDS cells are connected correctly?
    How do you know that the PIC is actually running and executing the code?

Similar Threads

  1. Stairwell light code from BS1 to PHP2.50a
    By vtt-info in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st December 2007, 17:32
  2. 16F877A problem: "coupled" digital values
    By Lupo83 in forum General
    Replies: 16
    Last Post: - 4th December 2007, 12:46
  3. A/D on 16F767 for light tracking.
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th November 2007, 05:56
  4. Reading a Light Dependent Resistor
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st October 2007, 05:29
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19

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