mmmries

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:

Most Liked

mmmries

mmmries

Mine arrived quite quickly! I’m in the UK so it was a short shipping distance, but hopefully yours arrives soon too

mmmries

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

jjcarstens

Nerves Core Team

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

tilobot_spin_led

Last Post!

mmmries

mmmries

Maybe this is way too ambitious, but I would love to be able to do something like this racing project as well

Where Next?

Popular in Discussions Top

AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31695 143
New
ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19740 150
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
slashdotdash
Phoenix Live View is now publicly available on GitHub. Here’s Chris McCord’s tweet announcing making it public.
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement