<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — obstacle avoiding car with remotexy bluetooth control]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=175</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=175&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in obstacle avoiding car with remotexy bluetooth control.]]></description>
		<lastBuildDate>Thu, 04 Jan 2018 00:41:59 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: obstacle avoiding car with remotexy bluetooth control]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1219#p1219</link>
			<description><![CDATA[<p>Hi Kanish,</p><p>Not sure if this helps give you some ideas. It&#039;s what i used for obstacle avoiding before i went onto RemoteXY. </p><p>I&#039;m looking to do something similar. A switch on the graphic interface that makes the car toggle between automatic obstacle avoiding/ remote control.</p><p>This is what i used for the obstacle avoiding robot. Note I set &#039;speed&#039; to 240, not max 255 (i.e. PWM voltage 0,255)</p><p>///////////////////////////////////////////////<br />//////Initialise pins///////////////////////////<br />///////////////////////////////////////////////<br />//////Global variables//////////////////////////<br />///////////////////////////////////////////////</p><br /><p>// connect motor controller pins to Arduino digital pins<br />// motor one<br />//right<br />int enA = 10;<br />int in1 = 9;<br />int in2 = 8;</p><p>//left<br />// motor two<br />int enB = 5;<br />int in3 = 7;<br />int in4 = 4; //changed from 6</p><br /><p>//sensor<br />const int trigPin = 11;<br />const int echoPin = 3;<br />long duration;<br />int distance;</p><p>//set the threshold for obstacle avoidance (cm)<br />int threshold = 20;</p><p>//set a counter. <br />//Modulo division will produce a crude randomiser for responding function<br />int count = 0;</p><br /><p>///////////////////////////////////////////////<br />///////////The set up function/////////////////<br />///////////////////////////////////////////////</p><br /><p>void setup() {<br />// put your setup code here, to run once:</p><p>//radar pins<br />pinMode(trigPin, OUTPUT);<br />pinMode(echoPin, INPUT);<br />Serial.begin(9600);</p><p>// set all the motor control pins to outputs<br />pinMode(enA, OUTPUT);<br />pinMode(enB, OUTPUT);<br />pinMode(in1, OUTPUT);<br />pinMode(in2, OUTPUT);<br />pinMode(in3, OUTPUT);<br />pinMode(in4, OUTPUT);<br />&nbsp; <br />//initial delay creates a pause before Jeff acts<br />delay(2000);<br />}</p><br /><p>///////////////////////////////////////////////<br />//////////////Radar function///////////////////<br />///////////////////////////////////////////////</p><p>void radar()<br />{<br />//updates the global variable distance<br />digitalWrite(trigPin, LOW);<br />delayMicroseconds(2);</p><p>digitalWrite(trigPin, HIGH);<br />delayMicroseconds(10);<br />digitalWrite(trigPin, LOW);</p><p>duration = pulseIn(echoPin, HIGH);</p><p>distance = duration*0.034/2;<br />Serial.print(&quot;distance: &quot;);<br />Serial.println(distance);<br />delay(10);<br />}</p><br /><p>/////////////////////////////////////////////////<br />////////Individual Motor functions///////////////<br />/////////////////////////////////////////////////<br />////////Stop, Forward and Back///////////////<br />/////////////////////////////////////////////////</p><p>//motor A stop<br />void right_stop()<br />{<br />&nbsp; // turn off motor A (Right)<br />&nbsp; digitalWrite(in1, LOW);<br />&nbsp; digitalWrite(in2, LOW);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enA, 200);<br />}</p><p>//motor B stop<br />void left_stop()<br />{<br />&nbsp; // turn off motor B (left)<br />&nbsp; digitalWrite(in3, LOW);<br />&nbsp; digitalWrite(in4, LOW);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enB, 200);<br />}</p><p>//motor A forward<br />void right_forward()<br />{<br />&nbsp; &nbsp; &nbsp; // turn on motor A (Right)<br />&nbsp; digitalWrite(in1, LOW);<br />&nbsp; digitalWrite(in2, HIGH);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enA, 200);<br />}</p><p>//motor B forward<br />void left_forward()<br />{<br />&nbsp; // turn on motor B (left)<br />&nbsp; digitalWrite(in3, LOW);<br />&nbsp; digitalWrite(in4, HIGH);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enB, 200);<br />}</p><p>//motor A backward<br />void right_backward()<br />{<br />&nbsp; &nbsp; &nbsp; // turn on motor A (Right)<br />&nbsp; digitalWrite(in1, HIGH);<br />&nbsp; digitalWrite(in2, LOW);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enA, 200);<br />}</p><p>//motor B backward<br />void left_backward()<br />{<br />&nbsp; // turn on motor B (left)<br />&nbsp; digitalWrite(in3, HIGH);<br />&nbsp; digitalWrite(in4, LOW);<br />&nbsp; // set speed to 200 out of possible range 0~255<br />&nbsp; analogWrite(enB, 200);<br />}</p><p>////////////////////////////////////////////<br />/////Driving functions//////////////////////<br />////////////////////////////////////////////<br />/////Forward, reverse, right, left, still///<br />////////////////////////////////////////////</p><p>void forward()<br />{<br />right_forward();<br />left_forward();<br />}</p><p>void reverse()<br />{<br />right_backward();<br />left_backward();<br />}</p><p>void right()<br />{<br />//A back, B forward<br />right_backward();<br />left_forward();<br />}</p><p>void left()<br />{<br />//B back, A forward<br />right_forward();<br />left_backward();<br />}</p><p>void still()<br />{<br />right_stop();<br />left_stop();&nbsp; <br />}</p><br /><p>///////////////////////////////////////////////<br />////////////Responding to obstacle function////<br />///////////////////////////////////////////////<br />//////Stop, reverse, and a random turn/////////<br />///////////////////////////////////////////////<br />///modulo division on count determines direction<br />////////////////////////////////////////////////</p><p>void respond()<br />{<br />&nbsp; if (count % 2 == false)<br />&nbsp; {<br />&nbsp; &nbsp; &nbsp;still();<br />&nbsp; &nbsp; delay(750);<br />&nbsp; &nbsp; reverse();<br />&nbsp; &nbsp; delay(500); <br />&nbsp; &nbsp; right();<br />&nbsp; &nbsp; delay(300);<br />&nbsp; } else {<br />&nbsp; &nbsp; &nbsp;still();<br />&nbsp; &nbsp; delay(750);<br />&nbsp; &nbsp; reverse();<br />&nbsp; &nbsp; delay(500);<br />&nbsp; &nbsp; left(); <br />&nbsp; &nbsp; delay(300);<br />&nbsp; }<br />}</p><br /><p>//////////////////////////////////////////////<br />//////////////////////////////////////////////<br />////////Main drive function///////////////////<br />//////////////////////////////////////////////</p><p>void drive()<br />{</p><p>//get the distance<br />radar();</p><p>&nbsp; // if the distance above threshold go forward<br />&nbsp; if (distance &gt; threshold) {<br />&nbsp; &nbsp; forward();<br />&nbsp; &nbsp; Serial.print(&quot;going forward &quot;);<br />&nbsp; } <br />&nbsp; <br />&nbsp; //If distance less than threshold respond<br />&nbsp; else {<br />&nbsp; &nbsp;respond();<br />&nbsp; Serial.print(&quot;responding &quot;);<br />&nbsp; }</p><p>//added serial readouts for testing and debugging.<br />}</p><br /><br /><p>///////////////////////////////////////////////<br />///////////Main loop function//////////////////<br />///////////////////////////////////////////////</p><p>void loop() {<br />// put your main code here, to run repeatedly:</p><p>count +=1;<br />drive();<br />//delay to steady the signal<br />delay(10);</p><p>}</p>]]></description>
			<author><![CDATA[null@example.com (richmcewan)]]></author>
			<pubDate>Thu, 04 Jan 2018 00:41:59 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1219#p1219</guid>
		</item>
		<item>
			<title><![CDATA[obstacle avoiding car with remotexy bluetooth control]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=638#p638</link>
			<description><![CDATA[<p>i want to merge code of remotexy car mentioned <a target="_blank" href="http://remotexy.com/en/examples/car/">http://remotexy.com/en/examples/car/</a><br />with sr04 ultrasonic sensor so that the robot stops or turns left/right when it detects a obstacle.<br />The code of ultrasonic sensor is <a target="_blank" href="http://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/">http://howtomechatronics.com/tutorials/ … r-hc-sr04/</a></p><p>how can I&nbsp; do that?<br />Any help/suggestion is appreciated..<br />Thank you.</p>]]></description>
			<author><![CDATA[null@example.com (kashish)]]></author>
			<pubDate>Sat, 06 May 2017 06:39:57 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=638#p638</guid>
		</item>
	</channel>
</rss>
