mmmries
Anyone interested in building Micromouse bots with Nerves?
After watching a recent youtube video about MicroMouse, I keep thinking about building my own and using it as a way to explore and learn about different kinds of code than the things I typically write for my job.
Is anyone else interested in this?
Update: People are interested, and we’re making a little community here
This thread ended up mostly focusing around controlling the Pimoroni Trilobot, but feel free to tag future threads/questions with toy_robot and I’ll try to link to resources from this first post:
- Motor control and button inputs got reverse engineered and there are modules to control them in this github repo
- Troubleshooting the SN3218 for controlling the RGB LEDs
- Jon Carstens got it working with sample code here: Anyone interested in building Micromouse bots with Nerves? - #36 by jjcarstens
- A thread to explore using the TMF8821 sensor for navigation
Most Liked
mmmries
Mine arrived quite quickly! I’m in the UK so it was a short shipping distance, but hopefully yours arrives soon too
mmmries
I started a github repo where I’ll keep my code for the project GitHub - mmmries/trilobot: An Elixir Nerves project for controlling a Pimoroni Trilobot · GitHub
I went ahead and ordered the Trilobot kit and TMF8821 board which can do time-of-flight distance measurments in an 8x8 grid across ~45° which I’m hoping will give me a lot more data about what’s in front of the bot.
My plan is to start with just getting trilobot assembled, get nerves running on the raspberry pi and reverse-engineer the python library well enough to control the motors and built-in distance sensor.
jjcarstens
I got the LED’s working. The address detection is not a standard so not always supported. Looks like that is the case here for the SN3218 in this setup. But I was able to write to the address and it was a matter of understanding the flow of how it expects to turn on.
You can dump this in IEx and get a little LED spin action with random colors:
{:ok, i2c} = Circuits.I2C.open("i2c-1")
# Docs say this should be 0xA8 (0b10101000), but the python uses
# this address and it works, so ¯\_(ツ)_/¯
addr = 0x54
# Enable LED control
Circuits.I2C.write(i2c, addr, <<0, 1>>)
# I don't know where the LED's are in this control register, so just turn
# them all on - #yolo
Circuits.I2C.write(i2c, addr, <<0x13, 255>>)
Circuits.I2C.write(i2c, addr, <<0x14, 255>>)
Circuits.I2C.write(i2c, addr, <<0x15, 255>>)
loop = fn l ->
# SN3218 supports 18 LEDs. The Trilobot seems to have 6 RGB leds with
# each color gamma tied to a single PWM LED register, effectively
# making the LED control triads of 3 register addresses
#
# | LED | Red register | Blue register | Green register |
# | ------------------ | ------------ | ------------- | -------------- |
# | LIGHT_FRONT_RIGHT | 1 | 2 | 3 |
# | LIGHT_FRONT_LEFT | 4 | 5 | 6 |
# | LIGHT_MIDDLE_LEFT | 7 | 8 | 9 |
# | LIGHT_REAR_LEFT | 10 | 11 | 12 |
# | LIGHT_REAR_RIGHT | 13 | 14 | 15 |
# | LIGHT_MIDDLE_RIGHT | 16 | 17 | 18 |
for led <- 1..6 do
# SN3218 has auto incrementing register addresses. This just means
# we calculate the first register (red) and then write 3 bytes which
# will write 1 byte to the 3 registers, starting with the initial (red)
reg = led * 3
rgb = for _ <- 1..3, do: Enum.random(0..255)
# Adjust the PWM for each RGB of LED N
Circuits.I2C.write(i2c, addr, [reg | rgb])
# Apply all the settings
Circuits.I2C.write(i2c, addr, <<0x16, 1>>)
# Little sleep gives a rotating effect on trilobot
:timer.sleep(100)
end
l.(l)
end
# Don't block our IEx
led_spin = spawn fn -> loop.(loop) end

Last Post!
mmmries
Maybe this is way too ambitious, but I would love to be able to do something like this racing project as well
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex











