Code for arduino

@ahmedk2, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

Something to read:

  1. Using millis() for timing. A beginners guide
  2. Demonstration code for several things at the same time
  3. pinMode() - Arduino Reference and digitalWrite() - Arduino Reference

For time calculations, make sure that you use variables of type unsigned long.