[EN] Arduino : repetition

Programming is an instruction for the processor to execute an instruction received. At a time, there is one instruction to process (in the case of non-parallel processing), once the instruction is completed, it saves the results of the commands in the working status register and prepares the next commands to be executed. This allows the operation to be performed individually from the first statement to the next, and the programmer can place the condition to separate the execution, for example, when a condition is true some instruction will be executed or any condition is not true, do not have to do or do something, etc. And finally, the function of the program can be repeated by the condition of iteration. For this reason, the basic programming principles consist of 3 types of work:

  • Execute one command at a time from top to bottom.
  • Able to add conditions of order processing.
  • Able to repeat the desired command.
Read More

[TH] Arduino : repetition

การเขียนโปรแกรมเป็นการสั่งงานให้หน่วยประมวลผลกระทำตามคำสั่งที่ได้รับ โดย ณ​ เวลาหนึ่งจะมีคำสั่งเข้าประมวลผล 1 ชุด (กรณีที่ไม่ใช่การประมวลผลแบบคู่ขนาน) และเมื่อคำสั่งประมวลผลเสร็จสิ้นจะบันทึกผลการดำเนินคำสั่งเก็บในเรจิสเตอร์สถานะการทำงานแล้วเตรียมประมวลผคำสั่งถัดไป ทำให้การทำงานเป็นการทำทีละคำสั่งจากคำสั่งแรกไปยังคำสั่งถัด ๆ ไป และผู้เขียนโปรแกรมสามารถวางการทำงานให้กระทำตามเงื่อนไขเพื่อแยกการประมวลผล เช่น เมื่อเงื่อนไขใดเป็นจริงให้กระทำ หรือเงินไขใดไม่เป็นจริงไม่ต้องกระทำหรือกระทำสิ่งใด เป็นต้น และสุดท้ายการทำงานของโปรแกรมสามารถให้ทำซ้ำได้โดยอาศัยเงื่อนไขของการกระทำซ้ำ ด้วยเหตุนี้ หลักการเขียนโปรแกรมเบื้องต้นจึงประกอบไปด้วยการทำงาน 3 ลักษณะ คือ

  • กระทำครั้งละคำสั่งจากบนลงล่าง
  • สามารถเพิ่มเติมให้เกิดเงื่อนไขของการประมวลผลคำสั่ง
  • สามารถให้เกิดการทำซ้ำคำสั่งที่ต้องการ
Read More