What the heck am I doing wrong?


Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159

    Default What the heck am I doing wrong?

    I'm having some trouble figuring out something and hope someone here can help.

    I am doing a project to control the marker lights on a pace car for a race track. We will have
    strobes on the four corners and on the front of the mirrors, as well as four lights on the rear
    that will indicate 'pass left', 'pass right' and 'do not pass'.

    To that end, I have decided to use a 'time slice' scheme to control the lights. Based on switch
    inputs, there will be word or long-sized 'patterns' of bits to turn the outputs on or off, then a pause
    and move on to the next bit in the pattern.

    My problem is figuring out how to shift the bits out of the patterns to turn the output ports on and off.

    I had thought of using SHIFTRIGHT (>>) to shift the bits off the LSB end of the pattern to turn the
    port on or off based on it being a one or zero, but it would appear that SHIFTRIGHT discards the shifted
    bit and won't let it be used.

    My other thought was to use an index to address the bits individually, but I don't think this will work
    either. For example:

    Code:
    pattern var byte 'may be a word or even long in the actual program
    index var byte
    
    pattern = 01010101  'example pattern, not all will be this regular
    
    for index = 0 to 7
        PORTB.0 = pattern.index 'turn portb.0 on or off based on whether the bit is 0 or 1
        pause 100
    next index
    For some reason, the 'percent' sign vanished - it's supposed to be 'percent' 01010101

    I'm pretty sure that won't work either. What am I doing wrong? Any ideas how I can accomplish this? I know there
    must be a way, I'm just missing it. Perhaps a 'bit array'? Is that even possible?

    Thanks for any help,

    Andy
    Last edited by andywpg; - 13th March 2012 at 23:00.

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