Connect with us

stopwatch with AVR

Discussion in 'General Electronics Discussion' started by matin, Feb 13, 2021.

Scroll to continue with content
  1. matin

    matin

    7
    2
    Feb 10, 2018
    hi everyone, could you please add a pause button to this?
    I really appreciate it.
    I uploaded two files one is a video from the microcontroller operating (stopwatch.rar)
     

    Attached Files:

  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,444
    2,629
    Nov 17, 2011
    @matin : Unlikely anybody is going to load the full project and analyze it. Also code alone will not suffice to add a pause butto. You'll need to add it in hardware, too. Therefore:
    1. show us a schematic diagram of your circuit and wehre you want to add that button.
    2. show us the relevant code directly in a code box
      upload_2021-2-13_20-21-24.png

    3. Make yourself familiar with de-bouncing.
    4. Give us a hint where the pause button should be added and what action it should trigger in the code.
     

    Attached Files:

  3. matin

    matin

    7
    2
    Feb 10, 2018
    the only problem is that I only know the basics of coding so I cant do it by myself
    I guess I should use port D of the microcontroller and interrupts
    here is also the schematic
     

    Attached Files:

  4. matin

    matin

    7
    2
    Feb 10, 2018
    I found this code but it uses atmega32 but I have only atmega16
     

    Attached Files:

  5. Harald Kapp

    Harald Kapp Moderator Moderator

    11,444
    2,629
    Nov 17, 2011
    Physically connect the pause button in the same way as the other two button. Use e.g. PD2, so you can use the interrupt INT0 to pause the counter.
    I tried to load your code. I get an error when loading the project :(
    Anyway I managed to read the C source file "gfuhgj.c" Where did you get it from? It is so ugly formatted no comments to explain what's going on, cryptic filenames ...
    "delay()" is used for timing: doesn't make for a precise stopwatch.
    Regardless of that: to pause the counter you can insert this code (replace the existing code without if:
    Code:
    while (1)
        {
        ww();
        dg();
        if(PIND.2==1)
           sd();
        }
    Then the counter will pause while the pause button is pressed.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-