Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drive Your Code ~ Building an RC Car by Writing...

1.7k

Drive Your Code ~ Building an RC Car by Writing Only Ruby~

hachi (Hayao Kimura)

May 16, 2024
Tweet

Transcript

  1. About me Hachi (Hayao Kimura) X: @hachiblog Web Application Engineer

    at freee K.K. Co-Founder of Kyobashi.rb. (Osaka)
  2. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan Do you think you can build an RC car just by writing Ruby?
  3. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan What are the annoying aspects of electronic work?
  4. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan Right, it's setting up the environment.
  5. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan But it's no longer necessary for us Rubyists!
  6. How to use R2P2 Just three step ✦Download R2P2 uf2

    file from R2P2 latest release ✦Connect a Raspberry Pi Pico to the PC
  7. How to use R2P2 Just three step ✦Download R2P2 uf2

    file from R2P2 latest release ✦Connect a Raspberry Pi Pico to the PC
  8. How to use R2P2 Just three step ✦Download R2P2 uf2

    file from R2P2 latest release ✦Connect a Raspberry Pi Pico to the PC ✦Drag and Drop to install R2P2 on the Raspberry Pi Pico
  9. How to use R2P2 Just three step ✦Download R2P2 uf2

    file from R2P2 latest release ✦Connect a Raspberry Pi Pico to the PC ✦Drag and Drop to install R2P2 on the Raspberry Pi Pico
  10. How to use R2P2 Just three step ✦Download R2P2 uf2

    file from R2P2 latest release ✦Connect a Raspberry Pi Pico to the PC ✦Drag and Drop to install R2P2 on the Raspberry Pi Pico That's it! Just write Ruby code in an editor afterward.
  11. I write such code: Controller side ✦Read and send joystick

    values Car side ✦Use the received values to drive motors
  12. Controller code Read Joystick voltage Transmit joystick voltage values to

    the car Of course, the JoyStick class and Twelite class are defined beforehand. The ADC and UART classes used within these classes are bundled with PicoRuby, and you can use them simply by requiring them.
  13. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  14. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  15. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  16. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  17. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  18. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  19. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors
  20. Car code Receive joystick voltage values from the controller Calculate

    voltage of two motors Update voltage of motors Similarly to the controller, classes such as the Motor class and the Receiver class are defined beforehand. PWM, UART classes are also bundled in PicoRuby
  21. Install codes to Picos When you place code as app.rb

    in the home directory of R2P2, it will execute upon the startup of the Pico. Install the code for both the controller and the car on their respective Picos.
  22. Install codes to Picos When you place code as app.rb

    in the home directory of R2P2, it will execute upon the startup of the Pico. Install the code for both the controller and the car on their respective Picos.
  23. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan This completes the RC car!
  24. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan I was really able to do microcontroller programming just by writing Ruby! Applause! 🎉🎉🎉🎉🎉🎉🎉🎉
  25. Wrap up PicoRuby and R2P2 are wonderful software If you

    want to try out the RC car or read the code, please come and talk to me! The company I work for, freee K.K., has a booth set up. We have code golf and accounting quiz, so please stop by! (You might even be able to play with remote control cars!)
  26. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan Enjoy electronics projects with R2P2!