Maker Pro
Maker Pro

stopwatch with AVR

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)
 

Attachments

  • stopwatch.rar
    739.1 KB · Views: 3
  • codes.zip
    13.7 KB · Views: 2

Harald Kapp

Moderator
Moderator
@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.
 

Attachments

  • upload_2021-2-13_20-21-17.png
    upload_2021-2-13_20-21-17.png
    10.7 KB · Views: 1
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
 

Attachments

  • Screenshot.png
    Screenshot.png
    28.8 KB · Views: 4
I found this code but it uses atmega32 but I have only atmega16
 

Attachments

  • Chronometer.rar
    42.8 KB · Views: 0

Harald Kapp

Moderator
Moderator
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.
 
Top