Change Tick Sound

Store Forums Game Timer Pro General Discussion Change Tick Sound

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9579
    djairguilherme
    Participant

    Michael, I’m customizing the Game Timer Pro and would like to change the Tic Tac sound to something like the 24hr (frequency, 2.5khz) sound.
    I downloaded the source code and found in the Sound.cpp file this here:
    void tick (int vol) {
       boolean sound = (config.get (SOUND)! = SOUND_OFF);
       uint8_t volume_div [] = {255, 200, 150, 125, 100, 87, 50, 33, 22, 2};
       int frequency = 1000000/400; // << This second number is originally 2000
       int duty = frequency / volume_div [vol-1];
       int loopCount = (2 * ((float) frequency / 1000.0));
       for (int i = 0; i <loopCount; i ++) {
         if (sound) PORTD | = (1 << 2);
         delayMicroseconds (duty);
         if (sound) PORTD & = ~ (1 << 2);
         delayMicroseconds (frequency-duty);
       }
    }
    Is that just the change?
    When I upload to the card, can I select any card with the same ATMega328 (Arduino Nano)?

    Grateful for the attention!

    Djair

    #9580
    Michael
    Keymaster

    The number that was originally 2000 is the frequency in Hz, so change that to 2500.

    int frequency = 1000000/2500;

    The reason the tick doesn’t sound like a beep is because it is very short in duration, so to make it sound like a beep, you need to change the duration. Change this line:
    int loopCount = (2 * ((float) frequency / 1000.0));

    to something like this:

    int loopCount = (100 * ((float) frequency / 1000.0));

    to make it longer. Adjust the value 100 higher or lower so it sounds like the right duration to you.

    The Game Timer Pro is an Arduino Uno, so choose that board in your Arduino IDE.

    • This reply was modified 6 years, 7 months ago by Michael.
    #9584
    djairguilherme
    Participant

    Michael, thank you very much for the response. I’ve already made the change in the code but I’m having some difficulty uploading. I have two laptops here, one of them running Ubuntu and the other running Mac OS X. Initially I thought it might be some problem with my drivers, although I’ve already uploaded it to other boards here. I could not upload and none of them, and I get the sync error message on avrdude:

    avrdude: stk500_recv (): programmer is not responding
    avrdude: stk500_getsync () attempt 1 of 10: not in sync: resp = 0x00

    My question is this: do I need to put the 10uF capacitor between the DTR and the RESET pin of the ATMEGA328P or does the system work in the same way as the Arduino Mini (just connect the FTDI adapter to the Arduino pins)?

    I just thought the upload would be done the same way I upload my sketches to the Mini, but that’s not working.

    My FTDI adapter is the one here: https://www.amazon.com/Qunqi-FT232RL-Serial-Adapter-Arduino/dp/B014Y1IMNM and it has worked when I use the Mini Arduinos.

    Another question concerns the voltage of the FTDI adapter. Mine has a 3.3V or 5V selection jumper. Which one would be correct?

    Thanks in advance for your patience.

    #9585
    Michael
    Keymaster

    It is an ordinary Uno, no extra hardware is needed. The adapter you link to on Amazon says “Not genuine FTDI chip” and this is why it probably doesn’t work.

    In my experience, people have all kinds of problems when they don’t use legit FTDI adapters. That’s why I only sell genuine ones from Adafruit (the FTDI Friend) because they ensure they are genuine and then there are no problems. Yes, they cost more, but they always work.

    I used to sell cheap adapter cables from Sparkfun but I found that they had a 25% failure rate.

    #13427
    tawee1688
    Participant

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.