user70166: I need a short beep for every minute of change. I wrote a separate function. The signal duration should be 50 ms, the rest of the time the emitter connected to the A1 contact should be silent.
A really working sketch is shown below:
uint32_t mysound; // Variable for storing time (duration of the sound signal)
uint32_t myTimer1;
uint32_t t; //Time that always increases
byte seconds; // Seconds
byte minutes; // Minutes
int k = 1;
void setup()
{
  DDRC = B00000010; // Set pin A1 as output
  //      76543210
  Serial.begin(9600);
  myTimer1 = millis();
}

void loop()
{
  t = (millis() - myTimer1) / 1000; // Time in seconds
  seconds = t % 60; // when 60 seconds are reached, it is reset to zero
  minutes = t / 60 % 60; // Counts the minutes and drops to zero when 60 minutes are reached
  Serial.println(seconds);
  if (seconds == 0 && k)
  {
    sound();
  }
  if (seconds > 0) k = 1;
}

void sound()
{
  mysound = millis();
  while (millis() - mysound < 50)
  {
    PORTC = B00000010; // We set high voltage on pin A1 for a time of 50 ms
  }
  k = 0;
  PORTC = B00000000;
}


user42015: In addition to Qareke's answer, you also have a problem with the mysound variable. You only set this timestamp to millis() inside your millis() if statement. mysound is global and thus will be implicitly initialized with zero. So, by the time, that the code reaches the if statement, the difference between millis() and mysound is most likely already too big, thus the timestamp gets never set.
Solution: You need to move 2 lines around in your code:

Move the mysound = millis(); statement up into the if (seconds == 0) statement.
Move the sound(); statement outside of the if statement directly into the void loop() function (for example directly after the if (seconds == 0) statement).

Now the sound() function will always be executed, but it will only do a sound, if the timestamp was set to millis() previously, and then only for 50ms. Now we only need to make sure, that the timestamp variable mysound will only be set once, when the seconds get zero. You could either introduce a new flag variable for that, or you could just use the timestamp itself and check, if more than 1s passed since the last time the timestamp was set. So you need to change
if (seconds == 0)

to
if (seconds == 0 && millis() - mysound > 1100)

I used 1100 (1.1s) here, to make sure, that there is no bad edge case happening. Since seconds will only get zero every minute, that shouldn't be a problem.

user72031: Your myTimer1 in t = (millis() - myTimer1) / 1000; is not set

70166: <p>I need a short beep for every minute of change. I wrote a separate function. The signal duration should be 50 ms, the rest of the time the emitter connected to the A1 contact should be silent.</p>
<p>A really working sketch is shown below:</p>
<pre><code>uint32_t mysound; // Variable for storing time (duration of the sound signal)
uint32_t myTimer1;
uint32_t t; //Time that always increases
byte seconds; // Seconds
byte minutes; // Minutes
int k = 1;
void setup()
{
  DDRC = B00000010; // Set pin A1 as output
  //      76543210
  Serial.begin(9600);
  myTimer1 = millis();
}

void loop()
{
  t = (millis() - myTimer1) / 1000; // Time in seconds
  seconds = t % 60; // when 60 seconds are reached, it is reset to zero
  minutes = t / 60 % 60; // Counts the minutes and drops to zero when 60 minutes are reached
  Serial.println(seconds);
  if (seconds == 0 &amp;&amp; k)
  {
    sound();
  }
  if (seconds &gt; 0) k = 1;
}

void sound()
{
  mysound = millis();
  while (millis() - mysound &lt; 50)
  {
    PORTC = B00000010; // We set high voltage on pin A1 for a time of 50 ms
  }
  k = 0;
  PORTC = B00000000;
}
</code></pre>
 42015: <p>In addition to Qareke's answer, you also have a problem with the <code>mysound</code> variable. You only set this timestamp to <code>millis()</code> inside your <code>millis()</code> if statement. <code>mysound</code> is global and thus will be implicitly initialized with zero. So, by the time, that the code reaches the if statement, the difference between <code>millis()</code> and <code>mysound</code> is most likely already too big, thus the timestamp gets never set.</p>
<p><strong>Solution:</strong> You need to move 2 lines around in your code:</p>
<ul>
<li>Move the <code>mysound = millis();</code> statement up into the <code>if (seconds == 0)</code> statement.</li>
<li>Move the <code>sound();</code> statement outside of the if statement directly into the <code>void loop()</code> function (for example directly after the <code>if (seconds == 0)</code> statement).</li>
</ul>
<p>Now the <code>sound()</code> function will always be executed, but it will only do a sound, if the timestamp was set to <code>millis()</code> previously, and then only for 50ms. Now we only need to make sure, that the timestamp variable <code>mysound</code> will only be set once, when the seconds get zero. You could either introduce a new flag variable for that, or you could just use the timestamp itself and check, if more than 1s passed since the last time the timestamp was set. So you need to change</p>
<pre><code>if (seconds == 0)
</code></pre>
<p>to</p>
<pre><code>if (seconds == 0 &amp;&amp; millis() - mysound &gt; 1100)
</code></pre>
<p>I used <code>1100</code> (1.1s) here, to make sure, that there is no bad edge case happening. Since <code>seconds</code> will only get zero every minute, that shouldn't be a problem.</p>
 72031: <p>Your <code>myTimer1</code> in <code>t = (millis() - myTimer1) / 1000;</code> is not set</p>
