How to start a block of code after a certain time? I'm using a ATMega328P-PU on a breadboard as an arduino. How do you start a code after say 20 seconds have elapsed since startup?
Example code:-

if(condition)
{
     //Start sending morse code!
}


My current code uses millis() and fails miserably. The speaker does not get activated. I'm using the standard circuit mentioned at the Arduino website
My current code:-

time = millis();
  if(time&gt;=20000)
      txEnable=true;
      val = analogRead(analogPin);
  if(val!=0)
  {
    standby=false;

  }
  else
  standby=true;
  if(txEnable==true &amp;&amp; standby==true)
 {

  if(!callsignSender-&gt;continueSending())
    {
        callsignSender-&gt;startSending();
    }

 }
The following bare-minimum code will switch pin 13 to high after 20 seconds:

void setup() {                
  // assuming pin 13 has a LED connected (as on most Arduino boards)
  pinMode(13, OUTPUT); 
  digitalWrite(13, LOW); // would also work without this line
}

void loop() {
  unsigned long time = millis();
  if (time &gt;= 20000) {
    digitalWrite(13, HIGH);   // set the LED on
  }
}


Try if this works for you, i.e. if a LED connected to that pin will light up 20 seconds after reboot.

If not you will need to find the problem: Is your ATmega running at the correct speed? Is your code executed at all? Are the peripherals working?