5. กด Math เพอ่ื เลือก pick random 0 to 10 เปลี่ยนเป็น 1 to 6 6. กด Logic เพอ่ื เลือก if true then
7. เลือก 0 = 0 เปล่ียนเป็น dice = 1 8. กด Basic เพื่อเลือก Show leds 9. กดเลอื ก Show leds แตะ 1 จุด ทาไปเร่ือยๆจนถึง Show leds ที่ 6 ดงั รูป
10. ควบคุม
Boolean การเขยี นโปรแกรม Make Code Programming เป้าหมาย : เพอ่ื ใหเ้ รียนรู้ในส่ือการเรียนรู้ของ Boolean ผลโปรแกรม : คาส่ัง A และ B ข้ึนโชวต์ ามที่กาหนดเอาไว้ ลงิ ค์เข้าดูงาน : https://makecode.microbit.org/_h2AXsJ57LhYW ข้นั ตอนการเขยี นโปรแกรม 1.เขา้ ไปที่ Link : https://makecode.microbit.org เพอ่ื เขา้ หนา้ โปรแกรม make code คลิกเลือก New Project จะไดห้ นา้ ต่างดงั รูป
2. เลือก on start 3. กด Variable ต้งั ช่ือเป็น playerAscore ดงั รูป
4. กด Input เลอื ก on button A pressed
5. กดไปที่ Variable ต้งั คา่ ขอ้ ความเป็น CoinA แลว้ กดไปท่ี Math เลอื ก pick random true or false ดงั รูป 6. กดไปที่ Logic เลือก if true then else
7. กด 0 = 0 มาใส่ไวใ้ น true แลว้ เติม CoinA ไปใน 0 ตวั หนา้ เติม CoinB ไปใน 0 ตวั หลงั แลว้ กดไปที่ Variable เลือก change playerAscore by 1 มาเติมในช่อง ดงั รูป 8. กดไปที่ Basic เลือก show string แลว้ กดไปที่ Text เลือก join \"Hello\" \"World\" -+ แลว้ เปลี่ยนจาก \"Hello\" เป็น \"A\" จาก \"World\" เป็น playerAscore แลว้ กดไปท่ี Basic เลือก pause(ms) 100 แตเ่ ปลี่ยนเป็น 1000 แลว้ เลือก clear screen ทาแบบน้ีซ้า2รอบ แต่ เปล่ียนจาก \"A\" เป็น\"B\" ดงั รูป
9. กดไปท่ี Input เลือก on button B pressed กดไปท่ี Variable เลือก set playerAscore 0 ดงั รูป 10. ควบคุม
Array Pointer การเขียนโปรแกรม Make Code Programming เป้าหมาย : เพอื่ ใหเ้ รียนรู้ในสื่อการเรียนรู้ของ Array pointer ผลโปรแกรม : Array_One และ Array_Two แสดงผลตามตวั เลขท่ีกาหนด ลงิ ค์เข้าดงู าน : https://makecode.microbit.org/_gUR8RVc1aev2 ข้นั ตอนการเขยี นโปรแกรม 1.เขา้ ไปท่ี Link : https://makecode.microbit.org เพอื่ เขา้ หนา้ โปรแกรม make code คลิกเลือก New Project จะไดห้ นา้ ตา่ งดงั รูป
2.เลือก on start แลว้ ไปกดที่ Arrays กดเลือก set list to array of 0 1 -+ เปลี่ยนจาก list เป็น Array_One ดงั รูป 3. กด + 11 คร้ัง ใส่เลข 5-55 4. กดไปที่ Input เลือก on button A pressed แลว้ กดไปท่ี Basic เลือก show number แลว้ กดไปที่ Arrays เลอื ก list get value at 0 แตเ่ ปลี่ยนจาก list เป็น Array_One และ เปล่ียนจาก 0 เป็น 2 ดงั รูป
5. กดไปท่ี Basic เลือก on start แลว้ ไปกดที่ Arrays กดเลือก set list to array of 0 1 -+ เปลี่ยนจาก list เป็น Array_Two แลว้ ใส่คาลงไป ดงั รูป 6.กดไปท่ี Input เลอื ก on button B pressed แลว้ กดไปที่ Basic เลือก show number แลว้ กดไปที่ Arrays เลือก list get value at 0 แต่เปลี่ยนจาก list เป็น Array_Two และเปล่ียน จาก 0 เป็น 5 ดงั รูป
7. ควบคุม
Search