<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Switch_Case</id>
	<title>Arduino: Switch Case - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Switch_Case"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;action=history"/>
	<updated>2026-04-20T19:28:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66129&amp;oldid=prev</id>
		<title>Unknown user at 01:30, 3 October 2022</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66129&amp;oldid=prev"/>
		<updated>2022-10-03T01:30:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:30, 3 October 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sumber: https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sumber: https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;An &lt;/del&gt;if &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;statement allows you to choose between two discrete options&lt;/del&gt;, TRUE &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;or &lt;/del&gt;FALSE. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;When there are more than two options&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;you can use multiple &lt;/del&gt;if &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;statements&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;or you can use the &lt;/del&gt;switch &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;statement&lt;/del&gt;. Switch &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;allows you to choose between several discrete options&lt;/del&gt;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This tutorial shows you how to use it to switch between four desired states of a photo &lt;/del&gt;resistor: really dark, dim, medium, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;and &lt;/del&gt;bright.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Pernyataan &lt;/ins&gt;if &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;memungkinkan kita untuk memilih di antara dua opsi terpisah&lt;/ins&gt;, TRUE &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;atau &lt;/ins&gt;FALSE. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Bila ada lebih dari dua opsi&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;kita dapat menggunakan beberapa pernyataan &lt;/ins&gt;if, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;atau kita dapat menggunakan pernyataan &lt;/ins&gt;switch. Switch &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;memungkinkan kita untuk memilih di antara beberapa opsi diskrit&lt;/ins&gt;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Tutorial ini menunjukkan cara menggunakannya untuk beralih di antara empat status &lt;/ins&gt;resistor &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;foto yang diinginkan&lt;/ins&gt;: really dark, dim, medium, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;dan &lt;/ins&gt;bright&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Program ini pertama membaca fotoresistor. Kemudian ia menggunakan fungsi map() untuk memetakan outputnya ke salah satu dari empat nilai: 0, 1, 2, atau 3. Terakhir, ia menggunakan pernyataan switch() untuk mencetak satu dari empat pesan kembali ke komputer tergantung pada yang mana dari empat nilai dikembalikan&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This program first reads the photoresistor. Then it uses the map() function to map its output to one of four values: 0, 1, 2, or 3. Finally, it uses the switch() statement to print one of four messages back to the computer depending on which of the four values is returned.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Hardware Required==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Hardware Required==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot;&gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Circuit==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Circuit==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The photoresistor is connected to &lt;/del&gt;analog &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in &lt;/del&gt;pin 0 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;using a voltage divider circuit&lt;/del&gt;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;A &lt;/del&gt;10K ohm &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;resistor makes up the other side of the voltage divider&lt;/del&gt;, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;running from &lt;/del&gt;Analog &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in &lt;/del&gt;0 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to &lt;/del&gt;ground. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The &lt;/del&gt;analogRead() &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;function returns a range of about &lt;/del&gt;0 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to &lt;/del&gt;600 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;from this circuit in a reasonably lit indoor space&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Fotoresistor dihubungkan ke &lt;/ins&gt;analog &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;di &lt;/ins&gt;pin 0 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;menggunakan rangkaian pembagi tegangan&lt;/ins&gt;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Sebuah resistor &lt;/ins&gt;10K ohm &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;membentuk sisi lain dari pembagi tegangan&lt;/ins&gt;, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;berjalan dari &lt;/ins&gt;Analog &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;di &lt;/ins&gt;0 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;ke &lt;/ins&gt;ground. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Fungsi &lt;/ins&gt;analogRead() &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mengembalikan kisaran sekitar &lt;/ins&gt;0 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;hingga &lt;/ins&gt;600 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;dari sirkuit ini di ruang dalam ruangan yang cukup terang&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:Circuitswitchcase.png|center|200px|thumb]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:Circuitswitchcase.png|center|200px|thumb]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66128&amp;oldid=prev</id>
		<title>Unknown user at 01:23, 3 October 2022</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66128&amp;oldid=prev"/>
		<updated>2022-10-03T01:23:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;amp;diff=66128&amp;amp;oldid=66098&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66098&amp;oldid=prev</id>
		<title>Unknown user: Created page with &quot;Sumber: https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase  An if statement allows you to choose between two discrete options, TRUE or FALSE. When there a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Switch_Case&amp;diff=66098&amp;oldid=prev"/>
		<updated>2022-09-28T11:38:57Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Sumber: https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase  An if statement allows you to choose between two discrete options, TRUE or FALSE. When there a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase&lt;br /&gt;
&lt;br /&gt;
An if statement allows you to choose between two discrete options, TRUE or FALSE. When there are more than two options, you can use multiple if statements, or you can use the switch statement. Switch allows you to choose between several discrete options. This tutorial shows you how to use it to switch between four desired states of a photo resistor: really dark, dim, medium, and bright.&lt;br /&gt;
&lt;br /&gt;
This program first reads the photoresistor. Then it uses the map() function to map its output to one of four values: 0, 1, 2, or 3. Finally, it uses the switch() statement to print one of four messages back to the computer depending on which of the four values is returned.&lt;br /&gt;
&lt;br /&gt;
Hardware Required&lt;br /&gt;
Arduino Board&lt;br /&gt;
&lt;br /&gt;
photoresistor, or another analog sensor&lt;br /&gt;
&lt;br /&gt;
10k ohm resistors&lt;br /&gt;
&lt;br /&gt;
hook-up wires&lt;br /&gt;
&lt;br /&gt;
breadboard&lt;br /&gt;
&lt;br /&gt;
Circuit&lt;br /&gt;
The photoresistor is connected to analog in pin 0 using a voltage divider circuit. A 10K ohm resistor makes up the other side of the voltage divider, running from Analog in 0 to ground. The analogRead() function returns a range of about 0 to 600 from this circuit in a reasonably lit indoor space.&lt;br /&gt;
&lt;br /&gt;
circuit&lt;br /&gt;
&lt;br /&gt;
Schematic&lt;br /&gt;
schematic&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
  Switch statement&lt;br /&gt;
&lt;br /&gt;
  Demonstrates the use of a switch statement. The switch statement allows you&lt;br /&gt;
  to choose from among a set of discrete values of a variable. It&amp;#039;s like a&lt;br /&gt;
  series of if statements.&lt;br /&gt;
&lt;br /&gt;
  To see this sketch in action, put the board and sensor in a well-lit room,&lt;br /&gt;
  open the Serial Monitor, and move your hand gradually down over the sensor.&lt;br /&gt;
&lt;br /&gt;
  The circuit:&lt;br /&gt;
  - photoresistor from analog in 0 to +5V&lt;br /&gt;
  - 10K resistor from analog in 0 to ground&lt;br /&gt;
&lt;br /&gt;
  created 1 Jul 2009&lt;br /&gt;
  modified 9 Apr 2012&lt;br /&gt;
  by Tom Igoe&lt;br /&gt;
&lt;br /&gt;
  This example code is in the public domain.&lt;br /&gt;
&lt;br /&gt;
  https://www.arduino.cc/en/Tutorial/BuiltInExamples/SwitchCase&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// these constants won&amp;#039;t change. They are the lowest and highest readings you&lt;br /&gt;
// get from your sensor:&lt;br /&gt;
const int sensorMin = 0;      // sensor minimum, discovered through experiment&lt;br /&gt;
const int sensorMax = 600;    // sensor maximum, discovered through experiment&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  // initialize serial communication:&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  // read the sensor:&lt;br /&gt;
  int sensorReading = analogRead(A0);&lt;br /&gt;
  // map the sensor range to a range of four options:&lt;br /&gt;
  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);&lt;br /&gt;
&lt;br /&gt;
  // do something different depending on the range value:&lt;br /&gt;
  switch (range) {&lt;br /&gt;
    case 0:    // your hand is on the sensor&lt;br /&gt;
      Serial.println(&amp;quot;dark&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
    case 1:    // your hand is close to the sensor&lt;br /&gt;
      Serial.println(&amp;quot;dim&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
    case 2:    // your hand is a few inches from the sensor&lt;br /&gt;
      Serial.println(&amp;quot;medium&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
    case 3:    // your hand is nowhere near the sensor&lt;br /&gt;
      Serial.println(&amp;quot;bright&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
  }&lt;br /&gt;
  delay(1);        // delay in between reads for stability&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Learn more&lt;br /&gt;
You can find more basic tutorials in the built-in examples section.&lt;br /&gt;
&lt;br /&gt;
You can also explore the language reference, a detailed collection of the Arduino programming language.&lt;br /&gt;
&lt;br /&gt;
Last revision 2015/08/11 by SM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase&lt;/div&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
</feed>