Slide 1

Slide 1 text

Drive Your Code Building an RC Car by Writing Only Ruby Hayao Kimura

Slide 2

Slide 2 text

About me Hachi (Hayao Kimura) X: @hachiblog Web Application Engineer at freee K.K. Co-Founder of Kyobashi.rb. (Osaka)

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan I made it!

Slide 5

Slide 5 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan Demo

Slide 6

Slide 6 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan Demo

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan But it's no longer necessary for us Rubyists!

Slide 10

Slide 10 text

How? Picoruby ✦Ruby implementation for one-chip microcontrollers R2P2 ✦Microcontroller framework created with Picoruby

Slide 11

Slide 11 text

How to use R2P2 Just three step ✦Download R2P2 uf2 file from R2P2 latest release

Slide 12

Slide 12 text

How to use R2P2 Just three step ✦Download R2P2 uf2 file

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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.

Slide 18

Slide 18 text

Controller Circuit

Slide 19

Slide 19 text

Car Circuit

Slide 20

Slide 20 text

I write such code: Controller side ✦Read and send joystick values Car side ✦Use the received values to drive motors

Slide 21

Slide 21 text

Controller code Read Joystick voltage Transmit joystick voltage values to the car

Slide 22

Slide 22 text

Controller code Read Joystick voltage Transmit joystick voltage values to the car

Slide 23

Slide 23 text

Controller code Read Joystick voltage Transmit joystick voltage values to the car

Slide 24

Slide 24 text

Controller code Read Joystick voltage Transmit joystick voltage values to the car

Slide 25

Slide 25 text

Controller code Read Joystick voltage Transmit joystick voltage values to the car

Slide 26

Slide 26 text

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.

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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.

Slide 36

Slide 36 text

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.

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan I was really able to do microcontroller programming just by writing Ruby! Applause! 🎉🎉🎉🎉🎉🎉🎉🎉

Slide 39

Slide 39 text

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!)

Slide 40

Slide 40 text

May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt, Okinawa, Japan Enjoy electronics projects with R2P2!