Proton BASIC Compiler - 4 digit Keypad Number entry converted to a Word variable?


  • PicŪ Basic


  • 4 digit Keypad Number entry converted to a Word variable?

    I am controlling a door latch with a 16F870 and MOSFET. (I am fully documenting this and will look to post when all together)
    I currently have a static variable LatchTime hardcoded.
    I am in the process of converting this code to allow the LatchTime to be a user variable entered via the keypad. I have thought about the process and wanted to see if anybody had come up with a simple and efficient process or is this the way?

    Example code to illustrate the theory (Not tested: as at work - Lunch Hour)

    Dim Key1 as Word
    Dim Key2 as Word
    Dim Key3 as Byte
    Dim Key4 as Byte

    Dim LatchTime as Word

    Key1 = Key1 * 1000
    Key2 = Key2 * 100
    Key3 = Key3 * 10
    Key4 = Key4 * 1 ' Not required, but for illustration

    LatchTime = Key1 + Key2 + Key3 + Key4

    Latch High
    DelayMS LatchTime
    Latch Low

    and also record this in the internal E2Prom.
    This article was originally published in forum thread: 4 digit Keypad Number entry converted to a Word variable? started by Grant34 View original post
  • Recent Activity

    geoff_c-79

    18F47K40 Port B issue

    Thread Starter: geoff_c

    Im having a problem with Port B on the 18F47K40. This is the first time Ive used a micro with the PPS so im guessing i missed something simple. Port...

    geoff_c Today, 07:35 Go to last post
    david-48000

    Migrating a monitored alarm from copper to GSM.

    Thread Starter: david

    Hi All, I need to migrate a monitored house alarm from the present copper line to GSM so we can eventually adopt a fiber system that the telcos are...

    david Today, 10:07 Go to last post
    charliecoultas-16125

    Baud rate problem

    Thread Starter: charliecoultas

    I am trying to run one of the USARTs on a 24HJ128GP502 at 115,200 bits/second. I thought I had defined the clock frequency wrong but Delayms gives...

    charliecoultas Today, 09:07 Go to last post