<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="sv">
	<id>https://wikiskola.se/index.php?action=history&amp;feed=atom&amp;title=Avst%C3%A5ndssensor_och_Busser_f%C3%B6r_Adafruit_ESP_Feather</id>
	<title>Avståndssensor och Busser för Adafruit ESP Feather - Versionshistorik</title>
	<link rel="self" type="application/atom+xml" href="https://wikiskola.se/index.php?action=history&amp;feed=atom&amp;title=Avst%C3%A5ndssensor_och_Busser_f%C3%B6r_Adafruit_ESP_Feather"/>
	<link rel="alternate" type="text/html" href="https://wikiskola.se/index.php?title=Avst%C3%A5ndssensor_och_Busser_f%C3%B6r_Adafruit_ESP_Feather&amp;action=history"/>
	<updated>2026-05-12T01:14:28Z</updated>
	<subtitle>Versionshistorik för denna sida på wikin</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wikiskola.se/index.php?title=Avst%C3%A5ndssensor_och_Busser_f%C3%B6r_Adafruit_ESP_Feather&amp;diff=53424&amp;oldid=prev</id>
		<title>Hakan: Skapade sidan med &#039;Kodexempel  &lt;pre&gt; //Defining the pins and variables const int trigPin = 27; const int echoPin = 13; const int freq = 2000; const int channel = 0; const int resolution = 8;   l...&#039;</title>
		<link rel="alternate" type="text/html" href="https://wikiskola.se/index.php?title=Avst%C3%A5ndssensor_och_Busser_f%C3%B6r_Adafruit_ESP_Feather&amp;diff=53424&amp;oldid=prev"/>
		<updated>2019-12-02T22:12:16Z</updated>

		<summary type="html">&lt;p&gt;Skapade sidan med &amp;#039;Kodexempel  &amp;lt;pre&amp;gt; //Defining the pins and variables const int trigPin = 27; const int echoPin = 13; const int freq = 2000; const int channel = 0; const int resolution = 8;   l...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ny sida&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Kodexempel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Defining the pins and variables&lt;br /&gt;
const int trigPin = 27;&lt;br /&gt;
const int echoPin = 13;&lt;br /&gt;
const int freq = 2000;&lt;br /&gt;
const int channel = 0;&lt;br /&gt;
const int resolution = 8;&lt;br /&gt;
 &lt;br /&gt;
long duration;&lt;br /&gt;
long distance;&lt;br /&gt;
 &lt;br /&gt;
void setup() {&lt;br /&gt;
  //Initiate serial monitor&lt;br /&gt;
  Serial.begin (9600);&lt;br /&gt;
 &lt;br /&gt;
  //Specifies the pins behavior&lt;br /&gt;
  pinMode(trigPin, OUTPUT);&lt;br /&gt;
  pinMode(echoPin, INPUT);&lt;br /&gt;
&lt;br /&gt;
  ledcSetup(channel, freq, resolution);&lt;br /&gt;
  ledcAttachPin(12, channel);&lt;br /&gt;
  ledcWrite(channel, 10);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void loop() {&lt;br /&gt;
  //Sending a LOW pulse to clear the trigPin&lt;br /&gt;
  //and sets the trigger to a HIGH pulse for 10 microseconds&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
  delayMicroseconds(5);&lt;br /&gt;
  digitalWrite(trigPin, HIGH);&lt;br /&gt;
  delayMicroseconds(10);&lt;br /&gt;
  digitalWrite(trigPin, LOW);&lt;br /&gt;
 &lt;br /&gt;
  //Reads the echoPin and the time it&lt;br /&gt;
  //took for the HIGH pulse to return&lt;br /&gt;
  duration = pulseIn(echoPin, HIGH);&lt;br /&gt;
 &lt;br /&gt;
  //Calculating the distance in cm&lt;br /&gt;
  distance = (duration/2) / 29.1;&lt;br /&gt;
 &lt;br /&gt;
  //Checking to see if the discance is less than 400&lt;br /&gt;
  //to avoid getting alerts when object is out of range.&lt;br /&gt;
  if(distance &amp;lt; 400){&lt;br /&gt;
    Serial.print(&amp;quot;distance: &amp;quot;);&lt;br /&gt;
    Serial.println(distance);&lt;br /&gt;
    ledcWriteTone(channel, distance);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  delay(200);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hakan</name></author>
	</entry>
</feed>