<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.luntti.net/index.php?action=history&amp;feed=atom&amp;title=Stop_at_line_py_v2</id>
	<title>Stop at line py v2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.luntti.net/index.php?action=history&amp;feed=atom&amp;title=Stop_at_line_py_v2"/>
	<link rel="alternate" type="text/html" href="https://wiki.luntti.net/index.php?title=Stop_at_line_py_v2&amp;action=history"/>
	<updated>2026-04-09T04:36:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.luntti.net/index.php?title=Stop_at_line_py_v2&amp;diff=42&amp;oldid=prev</id>
		<title>Mol: Created page with &quot;&lt;languages /&gt;  &lt;translate&gt;  == Introduction == Stop at line is a simple program to demonstrate forwarding moving and color sensor. The robot stops when the color sensor finds...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.luntti.net/index.php?title=Stop_at_line_py_v2&amp;diff=42&amp;oldid=prev"/>
		<updated>2020-06-09T15:10:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;languages /&amp;gt;  &amp;lt;translate&amp;gt;  == Introduction == Stop at line is a simple program to demonstrate forwarding moving and color sensor. The robot stops when the color sensor finds...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Stop at line is a simple program to demonstrate forwarding moving and color sensor. The robot stops when the color sensor finds a darker area.&lt;br /&gt;
&lt;br /&gt;
=== Robot ===&lt;br /&gt;
This works for almost any robot but the example is made for Asimov.&lt;br /&gt;
&lt;br /&gt;
=== Sensors ===&lt;br /&gt;
The color sensor is needed.&lt;br /&gt;
The sensor convention is&lt;br /&gt;
#port 1 = touch, &lt;br /&gt;
#port 2 = gyro, &lt;br /&gt;
#port 3 = color, &lt;br /&gt;
#port 4 = infrared or ultrasonic&lt;br /&gt;
&lt;br /&gt;
== An Illuminating Example Video ==&lt;br /&gt;
&amp;lt;youtube&amp;gt;YJb6Cr7ID4w&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Theory ==&lt;br /&gt;
The program uses &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; enclose=&amp;quot;none&amp;quot;&amp;gt;steering.on()&amp;lt;/syntaxhighlight &amp;gt; function to set the robot going forward. The while loop checkes if the colour sensor finds a darker area, and quits after finding. There is a small pause in the loop.&lt;br /&gt;
&lt;br /&gt;
== An Example Code ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
# https://sites.google.com/site/ev3devpython/&lt;br /&gt;
&lt;br /&gt;
#Sensor port convention:&lt;br /&gt;
#port 3 = color&lt;br /&gt;
#port 1 = touch, port 2 = gyro, port 3 = color, port 4 = infrared or ultrasonic.&lt;br /&gt;
&lt;br /&gt;
from ev3dev2.sensor.lego import ColorSensor&lt;br /&gt;
from ev3dev2.motor import MoveSteering, OUTPUT_B, OUTPUT_C&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
steer_pair = MoveSteering(OUTPUT_B, OUTPUT_C)&lt;br /&gt;
steer_pair.on(steering=0, speed=10)&lt;br /&gt;
&lt;br /&gt;
cl = ColorSensor() &lt;br /&gt;
while cl.reflected_light_intensity &amp;gt; 50:&lt;br /&gt;
    sleep( 0.01 )&lt;br /&gt;
&lt;br /&gt;
steer_pair.off()&lt;br /&gt;
sleep(5)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises ==&lt;br /&gt;
1. Try the script with different velocities. Does it always stop? What is the sampling frequency of the color sensor?&lt;br /&gt;
&lt;br /&gt;
2. Change the program to stop on fourth line. How about tenth line? Does the velocity of the robot change your results?&lt;br /&gt;
&lt;br /&gt;
3. The robot goes a bit over the line. Change the code such that it will stop exactly at the beginning of the line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Asimov]]&lt;br /&gt;
[[Category: Color sensor py v2]]&lt;br /&gt;
[[Category: Python v2]]&lt;br /&gt;
[[Category: Coding]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mol</name></author>
	</entry>
</feed>