<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ขับเซอร์โว | INVENTOR.IN.TH</title>
	<atom:link href="https://www.inventor.in.th/home/tag/%E0%B8%82%E0%B8%B1%E0%B8%9A%E0%B9%80%E0%B8%8B%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B9%82%E0%B8%A7/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.inventor.in.th/home</link>
	<description>Magazine online for thai inventor</description>
	<lastBuildDate>Wed, 07 Sep 2022 13:07:58 +0000</lastBuildDate>
	<language>th</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.9</generator>

<image>
	<url>https://www.inventor.in.th/home/wp-content/uploads/2018/08/cropped-icon-inventor-32x32.png</url>
	<title>ขับเซอร์โว | INVENTOR.IN.TH</title>
	<link>https://www.inventor.in.th/home</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>ใช้ micro:bit กับเครื่องให้อาหารแมวอัตโนมัติ (Update-210220)</title>
		<link>https://www.inventor.in.th/home/microbit-with-automatic-cat-feeder/</link>
		
		<dc:creator><![CDATA[Editorial]]></dc:creator>
		<pubDate>Mon, 15 Jul 2019 14:25:19 +0000</pubDate>
				<category><![CDATA[Pets]]></category>
		<category><![CDATA[คุณทำเองได้ (DIY)]]></category>
		<category><![CDATA[microbit]]></category>
		<category><![CDATA[ขับเซอร์โว]]></category>
		<category><![CDATA[ไมโครบิต]]></category>
		<guid isPermaLink="false">https://www.inventor.in.th/home/?p=5166</guid>

					<description><![CDATA[<a href="https://www.inventor.in.th/home/microbit-with-automatic-cat-feeder/">ใช้ micro:bit กับเครื่องให้อาหารแมวอัตโนมัติ (Update-210220)</a> <a href="https://www.inventor.in.th/home">INVENTOR.IN.TH</a><p>เนื่องจากโครงงานเครื่องให้อาหารแมวอัตโนมัตินั้น มีผู้สนใจจำนวนมาก ส่วนใหญ่ไม่เคยเขียนโปรแกรมและไม่มีความรู้ด้านอิเล็กทรอนิกส์มาก่อน โดยในบทความกึ่งโคร</p>
The post <a href="https://www.inventor.in.th/home/microbit-with-automatic-cat-feeder/">ใช้ micro:bit กับเครื่องให้อาหารแมวอัตโนมัติ (Update-210220)</a> first appeared on <a href="https://www.inventor.in.th/home">INVENTOR.IN.TH</a>.]]></description>
										<content:encoded><![CDATA[<a href="https://www.inventor.in.th/home/microbit-with-automatic-cat-feeder/">ใช้ micro:bit กับเครื่องให้อาหารแมวอัตโนมัติ (Update-210220)</a> <a href="https://www.inventor.in.th/home">INVENTOR.IN.TH</a><p>เนื่องจาก<a href="https://www.inventor.in.th/home/%e0%b8%9b%e0%b8%a3%e0%b8%b0%e0%b8%94%e0%b8%b4%e0%b8%a9%e0%b8%90%e0%b9%8c%e0%b9%80%e0%b8%84%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%ab%e0%b9%89%e0%b8%ad%e0%b8%b2%e0%b8%ab%e0%b8%b2%e0%b8%a3%e0%b9%81%e0%b8%a1%e0%b8%a7%e0%b8%ad%e0%b8%b1%e0%b8%95%e0%b9%82%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b8%95%e0%b8%b4/" target="_blank" rel="noopener noreferrer">โครงงานเครื่องให้อาหารแมวอัตโนมัติ</a>นั้น มีผู้สนใจจำนวนมาก ส่วนใหญ่ไม่เคยเขียนโปรแกรมและไม่มีความรู้ด้านอิเล็กทรอนิกส์มาก่อน โดยในบทความกึ่งโครงงานนี้ จึงขอแนะนำบอร์ดไมโครคอนโทรลเลอร์ที่ทำหน้าที่เดียวกับบอร์ด POP-168 (Arduino) ที่แนะนำในโครงงานฯ และที่จะแนะนำในบทความนี้ก็คือบอร์ด micro:bit <a href="https://www.inventor.in.th/home/microbit-easy-coding/" target="_blank" rel="noopener noreferrer">(อ่านรายละเอียดเพิ่มเติม)</a> ที่เหมาะอย่างยิ่งสำหรับน้องๆ นักเรียน ที่ยังไม่เคยเขียนโปรแกรมมาก่อน</p>
<p>ดังนั้นในบทความนี้ ผู้เขียนขออนุญาตไม่กล่าวถึงขั้นตอนการสร้างตัวโครงของเครื่องให้อาหารแมว แต่จะกล่าวถึงเฉพาะการนำไมโครบิตมาทำส่วนควบคุมการจ่ายอาหารเท่านั้น หากต้องการดูการสร้างโครงของเครื่องแนะนำให้เปิดดูเนื้อหาเกี่ยวกับการสร้างเครื่องให้อาหารแมวอัตโนมัติแทนนะครับ <a href="https://www.inventor.in.th/home/%e0%b8%9b%e0%b8%a3%e0%b8%b0%e0%b8%94%e0%b8%b4%e0%b8%a9%e0%b8%90%e0%b9%8c%e0%b9%80%e0%b8%84%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%ab%e0%b9%89%e0%b8%ad%e0%b8%b2%e0%b8%ab%e0%b8%b2%e0%b8%a3%e0%b9%81%e0%b8%a1%e0%b8%a7%e0%b8%ad%e0%b8%b1%e0%b8%95%e0%b9%82%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b8%95%e0%b8%b4/" target="_blank" rel="noopener noreferrer">(คลิกดูโครงงานเครื่องให้อาหารแมวอัตโนมัติ)</a></p>
<p><span style="text-decoration: underline;"><span style="font-size: 24pt;">อุปกรณ์ที่ต้องใช้</span></span></p>
<p><span style="font-size: 14pt;">1. บอร์ด micro:bit V1 หรือ V2 ก็ได้</span><br />
<span style="font-family: Sarabun;">ใช้สำหรับสำหรับเขียนโปรแกรมเพื่อควบคุมการทำงาน <a href="https://c.lazada.co.th/t/c.G8o?url=https://www.lazada.co.th/products/microbit-v22-official-bbc-microbit-v22-i2677958382-s9645603036.html" target="_blank" rel="noopener noreferrer">(คลิกสั่งซื้อ)</a></span></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/microbit-001.jpg"><img decoding="async" class="alignnone wp-image-5159" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/microbit-001-1024x727.jpg" alt="" width="640" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/microbit-001.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/microbit-001-300x213.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/microbit-001-768x545.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p><span style="font-size: 14pt;">2. บอร์ด AX-microBIT+</span><br />
<span style="font-family: Sarabun;">สำหรับเชื่อมต่ออุปกรณ์อินพุต เอาต์พุต หรืออุปกรณ์ภายนอกอื่นๆ <a href="https://inex.co.th/home/product/ax-microbit/" target="_blank" rel="noopener noreferrer">(คลิกสั่งซื้อ)</a></span></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/AX-microBIT.jpg"><img decoding="async" class="alignnone wp-image-5163" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/AX-microBIT-1024x708.jpg" alt="" width="640" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/AX-microBIT.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/AX-microBIT-300x207.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/AX-microBIT-768x531.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p><span style="font-size: 14pt;">3. ZX-SONAR หรือ ZX-SONAR1M (ใช้แทน ZX-SONAR ได้)</span><br />
<span style="font-family: Sarabun;">แผงวงจรวัดระยะทางด้วยคลื่นอัลตร้าโซนิกแบบให้ผลการทำงานเป็นแรงดันไฟตรงแบบแอนะล็อก <a href="https://inex.co.th/home/product/zx-sonar/" target="_blank" rel="noopener noreferrer">(คลิกสั่งซื้อ ZX-SONAR)</a> <a href="https://inex.co.th/home/product/zx-sonar1m/" target="_blank" rel="noopener">(คลิกสั่งซื้อ ZX-SONAR1M)</a></span></p>
<p><a href="https://inex.co.th/home/product/zx-sonar/" target="_blank" rel="noopener noreferrer"><img decoding="async" loading="lazy" class="wp-image-7954 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar.png" alt="" width="645" height="645" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar.png 900w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar-300x300.png 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar-150x150.png 150w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar-768x768.png 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/zx-sonar-50x50.png 50w" sizes="(max-width: 645px) 100vw, 645px" /></a></p>
<p><span style="font-size: 14pt;">4. KSERVO-270J</span><br />
<span style="font-family: Sarabun;"> เซอร์โวมอเตอร์กำลังไฟฟ้าต่ำ ขั้วต่อเป็นแบบ JST 2.0 มม. ตัวเมีย 3 ขา สำหรับใช้งานไมโครคอนโทรลเลอร์สมัยใหม่ที่ใช้ไฟเลี้ยง 3.3V <a href="https://inex.co.th/home/product/kservo-270j/" target="_blank" rel="noopener noreferrer">(คลิกสั่งซื้อ)</a></span></p>
<p><a href="https://inex.co.th/home/product/kservo-270j/" target="_blank" rel="noopener noreferrer"><img decoding="async" loading="lazy" class=" wp-image-7955 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02.jpg" alt="" width="445" height="445" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02.jpg 900w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02-300x300.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02-150x150.jpg 150w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02-768x768.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/KSERVO-270J-02-50x50.jpg 50w" sizes="(max-width: 445px) 100vw, 445px" /></a></p>
<p><span style="font-size: 14pt;">5. อะแดปเตอร์ไฟตรง 9 โวลต์ <a href="https://inex.co.th/home/product/dc-adaptor-9v-2a/" target="_blank" rel="noopener noreferrer">(คลิกสั่งซื้อ)</a></span></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/dc-adaptor.jpg"><img decoding="async" class="alignnone wp-image-5167" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/dc-adaptor-1024x707.jpg" alt="" width="640" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/dc-adaptor.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/dc-adaptor-300x207.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/dc-adaptor-768x530.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p><span style="text-decoration: underline;"><span style="font-size: 24pt;">ขั้นตอนการเชื่อมต่ออุปกรณ์และพัฒนาโค้ดโปรแกรม</span></span></p>
<p><span style="font-size: 12pt;">(1) ติดตั้งบอร์ดไมโครบิตเข้ากับแผงวงจร AX-microBIT+  จากนั้นเชื่อมต่อโมดูลวัดระยะทาง กับจุดต่อ <span style="color: #ff0000;">1/AN1</span></span></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect.jpg"><img decoding="async" loading="lazy" class="wp-image-7958 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect.jpg" alt="" width="583" height="437" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect.jpg 1280w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect-300x225.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect-1024x768.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect-768x576.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-sonar-connect-1170x878.jpg 1170w" sizes="(max-width: 583px) 100vw, 583px" /></a></p>
<p>(2) เชื่อมต่อเซอร์โวมอเตอร์ เข้ากับจุดต่อ <span style="color: #ff0000;">12</span> ของแผงวงจร AX-microBIT+</p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect.jpg"><img decoding="async" loading="lazy" class=" wp-image-7957 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect.jpg" alt="" width="583" height="437" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect.jpg 1280w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect-300x225.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect-1024x768.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect-768x576.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-servo-connect-1170x878.jpg 1170w" sizes="(max-width: 583px) 100vw, 583px" /></a></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect.jpg"><img decoding="async" loading="lazy" class=" wp-image-7956 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect.jpg" alt="" width="581" height="436" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect.jpg 1280w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect-300x225.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect-1024x768.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect-768x576.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-connect-1170x878.jpg 1170w" sizes="(max-width: 581px) 100vw, 581px" /></a><br />
<em><span style="font-family: Sarabun;">ภาพแสดงการเชื่อมต่ออุปกรณ์ทั้งหมดเข้าด้วยกัน</span></em></p>
<p>(3) อ่านค่าจากโมดูลวัดระยะทาง (ZX-Sonar) ให้แสดงผลด้วย LED บนบอร์ดไมโครบิต เพื่อหาค่าระยะห่างเมื่อแมวเข้ามากินอาหารที่ชาม</p>
<p style="padding-left: 40px;">(3.1) วิธีการคือเปิดเว็บเบราเซอร์ไปที่ https://makecode.microbit.org/ ลากบล็อก <span style="color: #0000ff;"><strong>show number</strong></span> จากกลุ่มคำสั่ง <strong><span style="color: #0000ff;">Basic</span> </strong>วางในบล็อก <span style="color: #0000ff;"><strong>forever</strong></span> แล้วลากบล็อก <strong><span style="color: #ff0000;">analog read pin</span></strong> จากกลุ่มคำสั่ง <span style="color: #ff0000;"><strong>Pins</strong> </span>วางในบล็อก <span style="color: #3366ff;"><strong>show number </strong><span style="color: #000000;">โดยกำหนดให้เป็นจุด <span style="color: #ff0000;"><strong>P1</strong></span> (เพราะเราเชื่อมต่อเซนเซอร์วัดระยะทางไว้ที่ P1)</span></span></p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4.jpg"><img decoding="async" loading="lazy" class="size-full wp-image-7965 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4.jpg" alt="" width="1233" height="861" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4.jpg 1233w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4-300x209.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4-1024x715.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4-768x536.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/analog-read-4-1170x817.jpg 1170w" sizes="(max-width: 1233px) 100vw, 1233px" /></a></p>
<p style="padding-left: 40px;">(3.2) เสียบสาย <strong>microUSB</strong> เข้ากับบอร์ดไมโครบิตและคอมพิวเตอร์ จะพบไดรฟ์ที่ชื่อ MICROBIT ปรากฎขึ้นมาในเครื่องคอมพิวเตอร์ของเรา จากนั้นคลิกปุ่ม <span style="color: #cc99ff;"><strong>Download</strong> </span>(ด้านล่างซ้ายมือ) แล้วเลือกวางไฟล์โค้ดไปยังไดรฟ์ MICROBIT</p>
<p style="padding-left: 40px;">(3.3) ทดลองนำ ZX-Sonar เคลื่อนเข้าหาวัตถุในตำแหน่งที่เหมาะสม (ระยะห่างที่แมวเดินเข้ามาหาชามอาหาร) แล้วบันทึกค่าที่อ่านได้จากหน้าจอ LED ของ micro:bit  (ZX-Sonar จะให้ค่าต่ำลงเมื่อมีวัตถุเข้าใกล้) ในตัวอย่างนี้เราจะได้ค่า 95 เพื่อนำไปสร้างเงื่อนไขต่อไป</p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read.jpg"><img decoding="async" loading="lazy" class=" wp-image-7969 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read.jpg" alt="" width="468" height="266" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read.jpg 1280w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read-300x171.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read-1024x582.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read-768x437.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-analog-read-1170x665.jpg 1170w" sizes="(max-width: 468px) 100vw, 468px" /></a></p>
<p>&nbsp;</p>
<p>(4) วางบล็อกคำสั่งง่ายๆ ดังตัวอย่างต่อไปนี้ เพื่อควบคุมการทำงานเครื่องให้อาหารแมวอัตโนมัติ (ขออนุญาตข้ามการอธิบายบล็อกคำสั่งนะครับ เนื่องจากมันค่อนข้างง่ายลองไล่ตามดูก็จะเข้าใจ)</p>
<p>สั่งเกตที่ด้านซ้ายของโปรแกรมจะมีบอร์ดจำลองของไมโครบิตแสดงการทำงานตามโค้ดที่เราเขียนไว้แบบทันทีทันใด ทำให้ง่ายในการทดลองเขียนโค้ด</p>
<p><a href="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block.jpg"><img decoding="async" loading="lazy" class="size-full wp-image-7970 alignnone" src="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block.jpg" alt="" width="1330" height="815" srcset="https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block.jpg 1330w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block-300x184.jpg 300w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block-1024x627.jpg 1024w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block-768x471.jpg 768w, https://www.inventor.in.th/home/wp-content/uploads/2019/07/catfeeder-code-block-1170x717.jpg 1170w" sizes="(max-width: 1330px) 100vw, 1330px" /></a></p>
<p><span style="font-family: Sarabun;">จากบล็อกข้างต้นได้สร้างเงื่อนไขจากค่าของโมดูลวัดระยะทาง ZX-Sonar ที่เราอ่านได้จากขั้นตอนที่แล้ว โดยใช้บล็อก <span style="color: #008080;"><strong>if then else</strong></span> จากกลุ่มคำสั่ง <span style="color: #008080;"><strong>Logic </strong><span style="color: #000000;">มาเป็นส่วนสรางเงื่อนไข โดย</span></span></span><span style="font-family: Sarabun;">ถ้าค่าที่อ่านได้น้อยกว่า 95 ให้ทำตามคำสั่งในส่วน <span style="color: #008080; font-family: Kanit;"><strong>then</strong></span> (เงื่อนไจเป็นจริง) ที่ประกอบไปด้วย</span></p>
<ul>
<li><span style="font-family: Sarabun;">แสดงหน้ายิ้มด้วยบล็อกคำสั่ง <span style="color: #3366ff;"><strong>show icon</strong></span> (สามารถเลือกไอคอนได้มากถึง 40 แบบ) </span></li>
<li><span style="font-family: Sarabun;">สั่งให้เซอร์โวมอเตอร์หมุนด้วยบล็อก <span style="color: #ff0000;"><strong>servo write pin</strong></span> (จากกลุ่มคำสั่ง  <span style="color: #ff0000;"><strong>Pins</strong></span>) เลือกพอร์ต <span style="color: #ff0000;"><strong>P12</strong></span> และกำหนดองศาการหมุนเป็น 90 องศา เพื่อหมุนตีลูกบอลเปิดให้อาหารแมวหล่นลงมา </span></li>
<li><span style="font-family: Sarabun;">หน่วงเวลาการหมุน (ให้ค้างตำแหน่งไว้) 2 วินาที (ค่า 1000 = 1 วินาที) ด้วยบล็อกคำสั่ง <span style="color: #3366ff;"><strong>pause</strong> </span></span></li>
<li><span style="font-family: Sarabun;">สั่งให้เซอร์โวมอเตอร์หมุนด้วยบล็อก <span style="color: #ff0000;"><strong>servo write pin</strong></span> เลือกพอร์ต <span style="color: #ff0000;"><strong>P12</strong></span> และกำหนดองศาการหมุนเป็น 0 องศา เพื่อให้ก้านตีออกจากลูกบอลและกลับไปยังตำแหน่งเดิม</span></li>
<li><span style="font-family: Sarabun;">ใช้บล็อกคำสั่ง <strong><span style="color: #3366ff;">pause</span> </strong>หน่วงเวลาที่ต้องการ ในตัวอย่างจะเท่ากับ 12 วินาที (จริงๆ แล้วควรนานกว่านี้) ในส่วนการหน่วงเวลาส่วนที่สองนี้คือการเผื่อเวลาให้แมวกินเสร็จ ก็ลองพิจารณาดูนะครับ ว่าควรกำหนดค่าไว้กี่วินาที โดยค่า 1000 เท่ากับ 1 วินาที</span></li>
</ul>
<p><span style="font-family: Sarabun;">อีกส่วนหนึ่งคือส่วนที่หากค่าที่อ่านได้จาก ZX-Sonar มากกว่า 95 (เงื่อนไขเป็นเท็จ) แสดงว่าแมวยังไม่เดินมาที่ชามอาหาร ให้ข้ามไปทำส่วน <span style="color: #008080; font-family: Kanit;"><strong>else</strong></span> โดยให้แสดงเป็นรูปหัวใจกำลังเต้นด้วยบล็อกคำสั่งต่อไปนี้</span></p>
<ul>
<li><span style="font-family: Sarabun;">โชว์รูปหัวใจด้วยบล็อก <span style="color: #3366ff;"><strong>show icon</strong></span> แล้วเลือกไอคอนรูปหัวใจดวงใหญ่</span></li>
<li><span style="font-family: Sarabun;">หน่วงเวลา 100 มิลลิวินาที ด้วยบล็อก <strong><span style="color: #3366ff;">pause </span></strong></span></li>
<li><span style="font-family: Sarabun;">โชว์รูปหัวใจด้วยบล็อก <span style="color: #3366ff;"><strong>show icon</strong></span> แล้วเลือกไอคอนรูปหัวใจดวงเล็ก</span></li>
<li><span style="font-family: Sarabun;">หน่วงเวลา 100 มิลลิวินาที ด้วยบล็อก <strong><span style="color: #3366ff;">pause </span></strong></span></li>
</ul>
<p>เสร็จแล้วก็อย่าลืมดาวน์โหลดลงบนไมโครบิตแล้วทดสอบ</p>
<p>ทั้งหมดนี้ก็คือการใช้บอร์ด micro:bit มาควบคุมเครื่องให้อาหารแมวของเรา แทนการใช้บอร์ด Arduino ซึ่งง่ายและเหมาะสำหรับน้องๆ ที่ไม่เคยเคยโปรแกรมและไม่มีความรู้ด้านอิเล็กทรอนิกส์มาก่อน สำหรับใครที่ต้องการสร้างหรือใช้งานไมโครบิตในรูปแบบอื่นๆ สามารถสั่งซื้อหนังสือคู่มือไว้ศึกษาเพิ่มเติมได้จากลิงก์นี้เลย <a href="https://inex.co.th/home/product/book-microbit-coding-beginner/" target="_blank" rel="noopener noreferrer">https://inex.co.th/home/product/book-microbit-coding-beginner</a></p>
<p><a href="https://www.inventor.in.th/home/%e0%b8%9b%e0%b8%a3%e0%b8%b0%e0%b8%94%e0%b8%b4%e0%b8%a9%e0%b8%90%e0%b9%8c%e0%b9%80%e0%b8%84%e0%b8%a3%e0%b8%b7%e0%b9%88%e0%b8%ad%e0%b8%87%e0%b9%83%e0%b8%ab%e0%b9%89%e0%b8%ad%e0%b8%b2%e0%b8%ab%e0%b8%b2%e0%b8%a3%e0%b9%81%e0%b8%a1%e0%b8%a7%e0%b8%ad%e0%b8%b1%e0%b8%95%e0%b9%82%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b8%95%e0%b8%b4/" target="_blank" rel="noopener noreferrer"><span style="font-size: 14pt;"><strong>การประดิษฐ์โครงสร้างเครื่องให้อาหารแมว</strong></span></a></p>
<p><a href="https://www.inventor.in.th/home/microbit-easy-coding/" target="_blank" rel="noopener noreferrer"><strong><span style="font-size: 14pt;">บทความแนะนำ micro:bit</span></strong></a></p>
<hr />
<p>&nbsp;</p>The post <a href="https://www.inventor.in.th/home/microbit-with-automatic-cat-feeder/">ใช้ micro:bit กับเครื่องให้อาหารแมวอัตโนมัติ (Update-210220)</a> first appeared on <a href="https://www.inventor.in.th/home">INVENTOR.IN.TH</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
