<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://shawnreeves.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Distance_grapher</id>
	<title>Distance grapher - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://shawnreeves.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Distance_grapher"/>
	<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Distance_grapher&amp;action=history"/>
	<updated>2026-11-06T01:30:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://shawnreeves.net//wiki/index.php?title=Distance_grapher&amp;diff=2908&amp;oldid=prev</id>
		<title>Shawn: Categorizing in PT</title>
		<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Distance_grapher&amp;diff=2908&amp;oldid=prev"/>
		<updated>2024-06-16T22:09:53Z</updated>

		<summary type="html">&lt;p&gt;Categorizing in PT&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 14:09, 16 June 2024&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-l48&quot;&gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&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;=== Graphing ===&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;=== Graphing ===&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;div&gt;Once the circuit is set up, the HC-SR04 is pointing where you want it, the Arduino is connected to power, and the code is uploaded to the Arduino, turn on &amp;quot;Serial Plotter&amp;quot; from the Tools menu of the Arduino IDE. It will plot numbers it sees coming in the same serial port used to upload the code. Be sure the baud rate in Serial Plotter matches that in the code.&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;Once the circuit is set up, the HC-SR04 is pointing where you want it, the Arduino is connected to power, and the code is uploaded to the Arduino, turn on &amp;quot;Serial Plotter&amp;quot; from the Tools menu of the Arduino IDE. It will plot numbers it sees coming in the same serial port used to upload the code. Be sure the baud rate in Serial Plotter matches that in the code.&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;&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;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Physics teaching]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Shawn</name></author>
	</entry>
	<entry>
		<id>https://shawnreeves.net//wiki/index.php?title=Distance_grapher&amp;diff=2907&amp;oldid=prev</id>
		<title>Shawn: Created page with &quot;== Arduino and HC-SR04 distance grapher == We use any Arduino connected to a computer running the Arduino Integrated Development Environment, and an HC-SR04, a very inexpensiv...&quot;</title>
		<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Distance_grapher&amp;diff=2907&amp;oldid=prev"/>
		<updated>2024-06-16T22:07:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Arduino and HC-SR04 distance grapher == We use any Arduino connected to a computer running the Arduino Integrated Development Environment, and an HC-SR04, a very inexpensiv...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Arduino and HC-SR04 distance grapher ==&lt;br /&gt;
We use any Arduino connected to a computer running the Arduino Integrated Development Environment, and an HC-SR04, a very inexpensive ultrasonic distance sensor.&lt;br /&gt;
The program periodically sends a trigger signal to the sensor, which in turn emits a series of eight blips in ultrasonic sound. The sensor listens for the blips to return, all the while keeping the &amp;quot;echo&amp;quot; signal pin high. Meanwhile, as soon as the trigger signal is sent, the Arduino keeps track of how long the echo signal pin is high. When the echo signal pin returns to low, the Arduino calculates how long the time of flight was, divides by two, and multiplies by the speed of sound to get the distance measured.&lt;br /&gt;
&lt;br /&gt;
=== Circuit ===&lt;br /&gt;
It&amp;#039;s always smart to make connections while Arduino is not powered, connected to USB or otherwise. You can choose any input-output pin, but avoid the ones labeled RX and TX, 0 and 1, if you are using UNO or similar non-native-USB board. Here we use 4 and 5.&lt;br /&gt;
Arduino label &amp;lt;&amp;gt; HC-SR04 label:&lt;br /&gt;
* GND &amp;lt;&amp;gt; GND&lt;br /&gt;
* 5V &amp;lt;&amp;gt; VCC&lt;br /&gt;
* 4 &amp;lt;&amp;gt; TRIG&lt;br /&gt;
* 5 &amp;lt;&amp;gt; ECHO&lt;br /&gt;
&lt;br /&gt;
=== Arduino code ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const int soundMicrosecondsPerCentimeter = 29;&lt;br /&gt;
const int TRIG = 3;&lt;br /&gt;
const int ECHO = 5;&lt;br /&gt;
const unsigned long measurementPeriod = 100;//ms&lt;br /&gt;
unsigned long lastMeasurementTime = 0;&lt;br /&gt;
long duration, cm;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  // initialize serial communication:&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  pinMode(ECHO, INPUT);&lt;br /&gt;
  pinMode(TRIG, OUTPUT);&lt;br /&gt;
  digitalWrite(TRIG, LOW);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  if(millis()-lastMeasurementTime &amp;gt; measurementPeriod){&lt;br /&gt;
    lastMeasurementTime = millis();&lt;br /&gt;
    digitalWrite(TRIG, LOW);&lt;br /&gt;
    delayMicroseconds(2);&lt;br /&gt;
    digitalWrite(TRIG, HIGH);&lt;br /&gt;
    delayMicroseconds(10);&lt;br /&gt;
    digitalWrite(TRIG, LOW);&lt;br /&gt;
    duration = pulseIn(ECHO, HIGH);&lt;br /&gt;
    cm = duration/soundMicrosecondsPerCentimeter/2;&lt;br /&gt;
    Serial.print(cm);&lt;br /&gt;
    Serial.println(&amp;quot;cm&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Graphing ===&lt;br /&gt;
Once the circuit is set up, the HC-SR04 is pointing where you want it, the Arduino is connected to power, and the code is uploaded to the Arduino, turn on &amp;quot;Serial Plotter&amp;quot; from the Tools menu of the Arduino IDE. It will plot numbers it sees coming in the same serial port used to upload the code. Be sure the baud rate in Serial Plotter matches that in the code.&lt;/div&gt;</summary>
		<author><name>Shawn</name></author>
	</entry>
</feed>