edison science corner
Published © CC BY-NC-SA

ATOM - Line Follower Robot

I am building a cute, compact line follower robot using M5Stack Atom Matrix, IR sensors & motors.

BeginnerFull instructions provided3 hours329

Things used in this project

Hardware components

ATOM Matrix ESP32 Development Kit
M5Stack ATOM Matrix ESP32 Development Kit
×1
Battery, 3.7 V
Battery, 3.7 V
×1

Software apps and online services

M5Stack UIFlow 2.0

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Custom parts and enclosures

motor holder

tyre

Schematics

circuit digram

Code

python code

Python
import os, sys, io
import M5
from M5 import *
from hardware import ADC
from hardware import Pin
from hardware import RGB



adc32 = None
adc33 = None
pin19 = None
pin22 = None
rgb = None


left = None
right = None


def setup():
  global adc32, adc33, pin19, pin22, rgb, left, right

  M5.begin()
  Widgets.fillScreen(0x000000)

  adc32 = ADC(Pin(32), atten=ADC.ATTN_11DB)
  adc33 = ADC(Pin(33), atten=ADC.ATTN_11DB)
  pin19 = Pin(19, mode=Pin.OUT, pull=Pin.PULL_DOWN)
  pin22 = Pin(22, mode=Pin.OUT, pull=Pin.PULL_DOWN)
  rgb = RGB()
  rgb.set_screen([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
  rgb.set_brightness(20)


def loop():
  global adc32, adc33, pin19, pin22, rgb, left, right
  M5.update()
  left = adc32.read()
  right = adc33.read()
  print(left)
  if left <= 1000:
    pin19.on()
    rgb.set_screen([0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00])
  if right <= 1000:
    pin22.on()
    rgb.set_screen([0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00, 0x44ff00])
  if left >= 1000:
    pin19.off()
    rgb.set_screen([0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019])
  if right >= 1000:
    pin22.off()
    rgb.set_screen([0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019, 0xff0019])


if __name__ == '__main__':
  try:
    setup()
    while True:
      loop()
  except (Exception, KeyboardInterrupt) as e:
    try:
      from utility import print_error_msg
      print_error_msg(e)
    except ImportError:
      print("please update to latest firmware")

Credits

edison science corner
60 projects • 84 followers
Electronic enthusiast watch videos from here https://www.youtube.com/channel/UCVcOsUBmH4hzVSnmJA_i5SA

Comments