Search this site
Embedded Files
Skip to main content
Skip to navigation
Afterschool Engineering
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
Afterschool Engineering
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
More
Home
Course Outline
About Mr. Jonathan
Electronics
Introduction to Electronics
Basic Electronics Video Series
Soldering and Tools
Voltage Divider and Transistor Circuits
LED Circuits
LED Star Maps
Aurora Bear LED Project
Lightbot
Electronics Projects
Liquid Light Fountain
Discrete Logic Circuits
Lessons
Goals
Code Examples
#1 :Meet MicroBit
#2 Basic Programming Challenges
Flow Control and Logic
#3: Neopixels Extension
#4: Using Arrays-the Magic 8-ball
#5- Robotic car
#6-Robotcar programming
#9: Varying Speed with Analog Write
#10: Ultrasonic Sensor
#11: Radio Control
#12: ServoMotors
#13: Line Sensors and Line Following
#14: Robot Swarms
#17- Events
Arcade Games
Arcade Game-Brilliant Labs
Controlling Physical Systems
Serial Communication with Microbit
Micropython
LED Matrix 7219
Microbit as HID Keyboard
Bluetooth Controller App
Projects
Project Ideas
Reka-Bit Projects
Science Buddies Microbit Projects
Neopixel Traffic Light
Infinity Mirror
Trundle Wheel
Plant watering Machine
Weather Station BME280
Data Logging for Physics
2-player Maze Game
Bowling Game
Music with MicroPython
Musical Rounds
Dancing with Robots
Smart House
Brilliant Labs Projects
Tech note: Data Logging: Sensor Monitor
Remote Servo
Tech Note: Capacitive Sensing
DF Mini Mp3 Player
Tech Note:Photogate
Parts List
Cardboard Robots
Internet of Things
What is the Internet of Things?
Thingspeak IOT
IOT Weather Station
Pictoblox Activities
Thingspeak IOT-Microbit
Blynk IOT ESP8266
AI Projects
AI with Pictoblox
Teachable Machine
AI Voice Control Module
Fixed Command Words
Huskylens AI Camera
Assignment #13: Line Sensors and Line Following
Objectives:
Line following is a classic controls problem in robotics
A line is detected using a light sensor
Using 1 sensor, an edge can be detected
Using 2 sensors, a line can be detected
To not overshoot the line, the motor speed and turning rate needs to be limited
In place of light sensors, the compass sensor can be used to follow a heading
Connections:
Vcc(Red) to +3V
GND(Black) to GND Bus
Digital Out(White) to P6 and P7
Set LED Enable to FALSE( makes more pins available for sensors)
Line sensor challenges:
(1) Program the robot to go forward, stop when it sees a black line
(2) Program the robot to stop at the line for 5 seconds, then go forward until it sees the next line
(3) Using a second 'traffic light' microbit, send signals if the light is green(go), yellow(slow down), red (stop).
If the light is green, the robot will not stop at the line
If the light is yellow, the robot slows to half speed
If the light is red, the robot will stop at the stop line until the light turns green
Line Following with one sensor:
Partial Code- 1 line sensor(edge sensor)
Line following- 2 sensors:
3 conditions:
Sensor 1 sees black line---bear left
Sensor 2 sees black line-- bear right
Neither sensor sees black line- go straight
See code files at:
https://drive.google.com/drive/folders/1GO8HHW2ffzdaFsCYfPMH6Ts1XAlcb6EW?usp=sharing
Alternative: Follow a compass heading
Below: Linefollower2
Using a Neopixel strip to indicate sensor readings:
Report abuse
Page details
Page updated
Report abuse