Make me some code..


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    48

    Default Make me some code..

    This is my current circuit



    Can you make a code like this (in PICBASIC PRO):

    When you click the button a timer starts and when you push it again it stops, and after that the LED blinks with "your time"..


    Can anyone do this?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Angry

    My one and only serious Question ...

    How much do you give for that ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    I'd pay money to have somebody write code just to turn that LED on... (never mind anything else - assuming it's a standard LED)...

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Mel

    That looks too much like the intelligent automobile screen wiper timer ...

    Alain
    Last edited by Acetronics2; - 11th September 2007 at 19:48.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I just want some example code to understand how the timer works, but i quess i haft to figure it out myself..

  6. #6
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Exclamation

    I may be wrong, but . . .

    . . . I don't think that the LED will ever light up with any program!
    Last edited by RussMartin; - 11th September 2007 at 21:05.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  7. #7
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    ...Can anyone do this?
    I guess the consensus is: NO, nobody can, even if they were willing to do it.
    Last edited by SteveB; - 11th September 2007 at 22:09.

  8. #8
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    When you click the button a timer starts and when you push it again it stops, and after that the LED blinks with "your time"..
    As for this, there are an amazing number of examples for applications like this on the forum, as well as MeLabs own website, and the web in general.

    I seriously doubt someone is going to be kind enough to write the code for you out of pure generosity and goodwill. That’s not to say no one will be helpful. Do a little research and come back with more specific questions. The help you reap will be proportional to effort you sow.

    SteveB

  9. #9
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi,

    Russ is right about the LED. You are showing it backwards. Steve B is right also. There are more than enough examples of timers, blinking LEDs, and start/stop programs on this forum that if you sat down and organized them all, you would have a book on beginning to work with PICs. If you are looking for the quick fix, it ain't happening here. We will all be glad to offer advice once you have made some effort to try programming. Also I think you should connect your push button to the ground side of the circuit and make the resistor a pullup instead of pull down. (Nothing personal just a preference. This way you won't have to program the pin in an extra step.)

    Go to CODE EXAMPLES and SCHEMATICS to start your search.

    Good luck. When you get stuck, then ask!

    BobK

  10. #10
    Join Date
    Aug 2007
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I can try. No timer use
    Code:
    DEFINE OSC 4
    CMCON = 7
    ADCON1 = 7
    output PORTB.0
    input PORTA.4
    b0 var word
    b0 = 0
    HIGH PORTB.0
    pause 200
    
    main:   if PORTA.4 = 1 then enter
            goto main
    
    enter:        if porta.4 = 1 then enter
                
    tmecnt:    if PORTA.4 = 1 then extime
                  b0 = b0+1         
                   pause 100   ' Least count of time 100 ms
                  goto tmecnt
    
    extime:     if PORTA.4 = 1 then extime
    
    ledon:  b0 = b0 * 100
            LOW PORTB.0
            pause b0
            HIGH PORTB.0
            b0 = 0
            goto main
            end
    If code works, can i give my PayPal................ hehe
    Last edited by NF9Ω; - 12th September 2007 at 09:41. Reason: led state change
    Thought-habits can harden into character. So watch your thoughts.

    (__)

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


    Did you find this post helpful? Yes | No

    Default $10 Challenge...

    My challenge was to write a piece of code to make the LED in that schematic light... I can't see your code turning that LED on... never mind any timers or buttons, just simply illuminate the LED as wired in that schematic...

    As someone who likes to learn new things, it's worth it to me to know how to accomplish this in software (PICBasic, Proton, Assembler, C, Fortran, Cobol, Algol, whatever, I'm good for all flavours)...

    For those that want to take up the challenge... I'll save you some time and tell you that the piece of code below WON'T work...

    High PortB.0

    and neither will...

    Low PortB.0

    So... a US$10 challenge to the first person who lights the LED (a bog-standard, common or garden nothing special cheapo average LED) in that original schematic (which must remain unchanged) as shown in Post #1 above... and posts his or her working code in this thread...

  12. #12
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Melanie View Post
    My challenge was to write a piece of code to make the LED in that schematic light... I can't see your code turning that LED on... never mind any timers or buttons, just simply illuminate the LED as wired in that schematic...

    As someone who likes to learn new things, it's worth it to me to know how to accomplish this in software (PICBasic, Proton, Assembler, C, Fortran, Cobol, Algol, whatever, I'm good for all flavours)...

    So... a US$10 challenge to the first person who lights the LED (a bog-standard, common or garden nothing special cheapo average LED) in that original schematic (which must remain unchanged) as shown in Post #1 above... and posts his or her working code in this thread...
    It's a great challenge but I think it's worth more than $10! I'll add another $10 to the pot for the person who achieves it ;-). Now it's worth $20!

  13. #13
    Join Date
    Aug 2007
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    just simply illuminate the LED as wired in that schematic...
    Oh. BobK is right.
    LED will never illuminate according to circuit.
    Thought-habits can harden into character. So watch your thoughts.

    (__)

  14. #14
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    So... a US$10 challenge to the first person who lights the LED (a bog-standard, common or garden nothing special cheapo average LED) in that original schematic (which must remain unchanged) as shown in Post #1 above... and posts his or her working code in this thread...
    Quote Originally Posted by Kamikaze47
    How about: 'accidentally' cut the wire directly above the "16F628" in the circuit diagram, then PORTA.4=0, then PORTB.0=1, and press the button. LED=lit!
    I don't think this qualifies.

Similar Threads

  1. Code doesn't work on 16F648A
    By Mr_Joe in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2018, 22:09
  2. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  5. Can someone help me make a code for this:
    By joseph in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th May 2009, 22:03

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