Work wonders with iRobot’s Root® coding robots. Shop now >

View All Materials

Lesson:

Integrating Thunkable with the Python Playground

Coding,

Python,

Robotics

Experience Level

Intermediate

Duration

30-60 minutes

Group Size

Individual

Small Groups (2-4)

Compatible Robots

N/A

Details

Create a remote-control app to drive your robot around.

Downloads & Resources

Python Web Playground Thunkable App Builder Airtable

Integrating Thunkable (and Airtable) with the Python Web Playground

Setting Up Your Airtable and Python Playground Project

  1. Before starting with thunkable, follow the steps in the Learning Library lesson "Integrating Airtable with the Python Playground." There, you will create your own "cloud database" in Airtable and a Python project to control your robot.

  2. Once you've created your Airtable and Python Playground project, open them on your screen. You'll be referring to both pages as you build your Thunkable app.



Getting Started with Thunkable

  1. Visit Thunkable.com and create an account. Then create a new, blank project.

  2. Use the Design Elements on the left side of the page to drag out three buttons. Next, click each button and edit its data using the panel on the right side of the screen.
    • Name the first button "GoButton" and give the button text "Go"
    • Name the second button "SpinButton" and give the button text "Spin"
    • Name the third button "StopButton" and give the button text "Stop"


  3. To the extreme left of the page, click on the Data Source icon. Click the plus icon next to the Data Source title to open the Your Data Sources dialog box.
  4. In the Your Data Sources dialog, click "Create New"

  5. In the Create New DataSource dialog, click the Airtable icon.

  6. In the Add An Airtable Data Source dialog, first paste your Airtable API Key (If you do not have your API key, instructions for getting it can be found in the Learning Library lesson "Integrating Airtable with the Python Playground). Once you input your key, click the "Refresh" button. Click the drop-down in the Select Your Base section, and select the base Python Playground Controller. Then confirm by clicking "Create."

  7. Next, move to the bottom-right corner and click the button Add Blocks. This will send you to the coding screen.

  8. Next, use the code blocks to create the following program. Make sure that your base name and table name are correct. In the next step, we'll get your row id.

  9. To get your row id, open your Airtable base. Click on the blue bi-directional arrows next to the word "Forward" to view cell details. Direct your attention to the URL, which should now update to show the cell's URL. At the end of the URL, you'll see a string of text starting with "rec" before a question mark (?). This text is your row id. Copy and paste the row id into your Thunkable code blocks.


  10. Once your code is built, navigate to the top-right corner of the screen and press the Web Preview (play) button. This will activate your Thunkable app.

  11. Open your Airtable base and the Thunkable app side-by-side. Try pressing the buttons on your app to see if the values in cell 1 update to "Forward" "Spin" and "Stop." If they do not update, check that your data source is connected properly and that you are using the correct row id. You can also refer to this Thunkable tutorial for additional help.

Putting It All Together

  1. Open the Python Playground Project, Airtable base and the Thunkable app together on your screen.
  2. On the Python Playground page, click Connect to and pair to your robot. If your robot does not show in the dialog, make sure that it is powered on and not already connected via Bluetooth to another device.
  3. Press "Play" on the Python Playground to run your project. In the Console at the bottom, it should start printing the values of cell 1 in the Airtable base. Try clicking the "Go" button on your Thunkable app to drive your robot forward. If successful, you should be able to control your robot's driving with your Thunkable App!


Going Further

Looking to take your project to the next level? Try some of the following ideas!