<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="da">
	<id>https://www.htxarduino.dk/index.php?action=history&amp;feed=atom&amp;title=Afstand_programforslag</id>
	<title>Afstand programforslag - Versionshistorie</title>
	<link rel="self" type="application/atom+xml" href="https://www.htxarduino.dk/index.php?action=history&amp;feed=atom&amp;title=Afstand_programforslag"/>
	<link rel="alternate" type="text/html" href="https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;action=history"/>
	<updated>2026-07-29T03:50:59Z</updated>
	<subtitle>Versionshistorie for denne side i HTX Arduino</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=4392&amp;oldid=prev</id>
		<title>Bar: /* Referencer */</title>
		<link rel="alternate" type="text/html" href="https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=4392&amp;oldid=prev"/>
		<updated>2022-10-31T20:28:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Referencer&lt;/span&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;da&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Ældre version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Versionen fra 31. okt. 2022, 22:28&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-l186&quot;&gt;Linje 186:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linje 186:&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;==Referencer==&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;==Referencer==&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;&amp;lt;references /&amp;gt;&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;&amp;lt;references /&amp;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;&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;{{start-Arduino}}&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;&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;div&gt;[[Kategori:Projekter]]&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;[[Kategori:Projekter]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bar</name></author>
	</entry>
	<entry>
		<id>https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=17&amp;oldid=prev</id>
		<title>Bar: 1 version importeret</title>
		<link rel="alternate" type="text/html" href="https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=17&amp;oldid=prev"/>
		<updated>2022-10-19T13:00:09Z</updated>

		<summary type="html">&lt;p&gt;1 version importeret&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;da&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Ældre version&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Versionen fra 19. okt. 2022, 15:00&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;da&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(Ingen forskel)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Bar</name></author>
	</entry>
	<entry>
		<id>https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=16&amp;oldid=prev</id>
		<title>ard_&gt;Bar med 18. okt. 2020, 14:47</title>
		<link rel="alternate" type="text/html" href="https://www.htxarduino.dk/index.php?title=Afstand_programforslag&amp;diff=16&amp;oldid=prev"/>
		<updated>2020-10-18T14:47:09Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ny side&lt;/b&gt;&lt;/p&gt;&lt;div&gt;På denne side angives to forskellige løsninger til hvordan man kan få en afstandsmåler til at fungere.&lt;br /&gt;
&lt;br /&gt;
Løsningerne tager udgangspunkt i Ping eksemplet&amp;lt;ref&amp;gt;[https://www.arduino.cc/en/Tutorial/Ping Ping Tutorial] på www.arduino.cc&amp;lt;/ref&amp;gt;. Dette eksempel arbejder med et modul, hvor triggerbenet og echobenet fungerer på samme ben. Det kræver at man vender input og output hele tiden i målingen. De fleste af de moduler til afstandsmåling man kan købe i dag har de to ben delt op på hver sin pin.&lt;br /&gt;
==Løsning med Seriel port==&lt;br /&gt;
Koden herunder tager udgangspunkt i en afstandsmåler med 4 ben. VCC der skal til +5V og GND til GND. Echo-benet forbindes til pin 8 og trig-benet forbindes til ben 9.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  Ping))) Sensor&lt;br /&gt;
&lt;br /&gt;
  This sketch reads a PING))) ultrasonic rangefinder and returns the distance&lt;br /&gt;
  to the closest object in range. To do this, it sends a pulse to the sensor to&lt;br /&gt;
  initiate a reading, then listens for a pulse to return. The length of the&lt;br /&gt;
  returning pulse is proportional to the distance of the object from the sensor.&lt;br /&gt;
&lt;br /&gt;
  The circuit:&lt;br /&gt;
	- +V connection of the PING))) attached to +5V&lt;br /&gt;
	- GND connection of the PING))) attached to ground&lt;br /&gt;
	- ECHO connection of the PING))) attached to digital pin 8&lt;br /&gt;
  - TRIG connection of the PING))) attached to digital pin 9&lt;br /&gt;
&lt;br /&gt;
  created 3 Nov 2008&lt;br /&gt;
  by David A. Mellis&lt;br /&gt;
  modified 30 Aug 2011&lt;br /&gt;
  by Tom Igoe&lt;br /&gt;
  modified 28 Nov 2018 by Bent Arnoldsen&lt;br /&gt;
&lt;br /&gt;
  This example code is in the public domain.&lt;br /&gt;
&lt;br /&gt;
  http://www.arduino.cc/en/Tutorial/Ping&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// this constant won&amp;#039;t change. It&amp;#039;s the pin number of the sensor&amp;#039;s output:&lt;br /&gt;
const int trigPin = 9;&lt;br /&gt;
const int echoPin = 8;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  // initialize serial communication:&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  pinMode(trigPin, OUTPUT);&lt;br /&gt;
  pinMode(echoPin, INPUT);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  // establish variables for duration of the ping, and the distance result&lt;br /&gt;
  // in inches and centimeters:&lt;br /&gt;
  long duration, inches, cm;&lt;br /&gt;
&lt;br /&gt;
  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.&lt;br /&gt;
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
  delayMicroseconds(2);&lt;br /&gt;
  digitalWrite(trigPin, HIGH);&lt;br /&gt;
  delayMicroseconds(5);&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
&lt;br /&gt;
  duration = pulseIn(echoPin, HIGH);&lt;br /&gt;
&lt;br /&gt;
  // convert the time into a distance&lt;br /&gt;
  inches = microsecondsToInches(duration);&lt;br /&gt;
  cm = microsecondsToCentimeters(duration);&lt;br /&gt;
&lt;br /&gt;
  Serial.print(inches);&lt;br /&gt;
  Serial.print(&amp;quot;in \t&amp;quot;);&lt;br /&gt;
  Serial.print(cm);&lt;br /&gt;
  Serial.print(&amp;quot;cm&amp;quot;);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
&lt;br /&gt;
  delay(100);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
long microsecondsToInches(long microseconds) {&lt;br /&gt;
  return microseconds / 74 / 2;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
long microsecondsToCentimeters(long microseconds) {&lt;br /&gt;
  return microseconds / 29 / 2;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hardware til Serielport-løsningen===&lt;br /&gt;
For at få afstandsmåleren til at fungere på [[Serial Monitor]] anvendes følgende hardware:&amp;lt;br /&amp;gt;&lt;br /&gt;
[[fil:afstand_maal.png|400px|Afstandsmåler til Serial Monitor]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;Figur 2. Afstandsmåler til Serial Monitor&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==Løsning med Display og Seriel port==&lt;br /&gt;
Hvis man gerne vil have visningen på et display, så er der selvfølgelig mere hardware der skal kobles til, men visningen bliver mere brugervenlig, og Arduinoen kan fungere uden en computer tilsluttet.&lt;br /&gt;
&lt;br /&gt;
Det er følgende kode der skal anvendes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  Ping))) Sensor&lt;br /&gt;
&lt;br /&gt;
  This sketch reads a PING))) ultrasonic rangefinder and returns the distance&lt;br /&gt;
  to the closest object in range. To do this, it sends a pulse to the sensor to&lt;br /&gt;
  initiate a reading, then listens for a pulse to return. The length of the&lt;br /&gt;
  returning pulse is proportional to the distance of the object from the sensor.&lt;br /&gt;
&lt;br /&gt;
  The circuit:&lt;br /&gt;
	- +V connection of the PING))) attached to +5V&lt;br /&gt;
	- GND connection of the PING))) attached to ground&lt;br /&gt;
	- ECHO connection of the PING))) attached to digital pin 8&lt;br /&gt;
  - TRIG connection of the PING))) attached to digital pin 9&lt;br /&gt;
&lt;br /&gt;
  created 3 Nov 2008&lt;br /&gt;
  by David A. Mellis&lt;br /&gt;
  modified 30 Aug 2011&lt;br /&gt;
  by Tom Igoe&lt;br /&gt;
  modified 28 Nov 2018 by Bent Arnoldsen&lt;br /&gt;
&lt;br /&gt;
  This example code is in the public domain.&lt;br /&gt;
&lt;br /&gt;
  http://www.arduino.cc/en/Tutorial/Ping&lt;br /&gt;
*/&lt;br /&gt;
// include the library code:&lt;br /&gt;
#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// initialize the library with the numbers of the interface pins&lt;br /&gt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&lt;br /&gt;
&lt;br /&gt;
// this constant won&amp;#039;t change. It&amp;#039;s the pin number of the sensor&amp;#039;s output:&lt;br /&gt;
const int trigPin = 9;&lt;br /&gt;
const int echoPin = 8;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  // initialize serial communication:&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  pinMode(trigPin, OUTPUT);&lt;br /&gt;
  pinMode(echoPin, INPUT);&lt;br /&gt;
  // set up the LCD&amp;#039;s number of columns and rows:&lt;br /&gt;
  lcd.begin(16, 2);&lt;br /&gt;
  // Print a message to the LCD.&lt;br /&gt;
  lcd.print(&amp;quot;Afstandsmåler&amp;quot;);&lt;br /&gt;
  delay(2000);&lt;br /&gt;
  lcd.clear();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  // establish variables for duration of the ping, and the distance result&lt;br /&gt;
  // in inches and centimeters:&lt;br /&gt;
  long duration, inches, cm;&lt;br /&gt;
&lt;br /&gt;
  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.&lt;br /&gt;
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
  delayMicroseconds(2);&lt;br /&gt;
  digitalWrite(trigPin, HIGH);&lt;br /&gt;
  delayMicroseconds(5);&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
&lt;br /&gt;
  duration = pulseIn(echoPin, HIGH);&lt;br /&gt;
&lt;br /&gt;
  // convert the time into a distance&lt;br /&gt;
  inches = microsecondsToInches(duration);&lt;br /&gt;
  cm = microsecondsToCentimeters(duration);&lt;br /&gt;
&lt;br /&gt;
  Serial.print(inches);&lt;br /&gt;
  Serial.print(&amp;quot;in \t&amp;quot;);&lt;br /&gt;
  Serial.print(cm);&lt;br /&gt;
  Serial.print(&amp;quot;cm&amp;quot;);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
&lt;br /&gt;
  lcd.setCursor(0,0);&lt;br /&gt;
  lcd.print(&amp;quot;Afst. cm = &amp;quot;);&lt;br /&gt;
  lcd.print(cm);&lt;br /&gt;
  lcd.print(&amp;quot;    &amp;quot;);&lt;br /&gt;
  lcd.setCursor(0,1);&lt;br /&gt;
  lcd.print(&amp;quot;Tommer = &amp;quot;);&lt;br /&gt;
  lcd.print(inches);&lt;br /&gt;
  lcd.print(&amp;quot;    &amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  delay(100);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
long microsecondsToInches(long microseconds) {&lt;br /&gt;
  return microseconds / 74 / 2;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
long microsecondsToCentimeters(long microseconds) {&lt;br /&gt;
  return microseconds / 29 / 2;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===Hardware til Display-løsningen===&lt;br /&gt;
For at få displayet til at fungere anvendes følgende hardware:&amp;lt;br /&amp;gt;&lt;br /&gt;
[[fil:afstand_med_display.png|800px|Afstandsmåler med display]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;Figur 2. Afstandsmåler med display&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==Referencer==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
[[Kategori:Projekter]]&lt;/div&gt;</summary>
		<author><name>ard_&gt;Bar</name></author>
	</entry>
</feed>