5.Wifi Control Car

If you've ever dreamed of creating your own remote controlled car, we've got good news! With the help of Robo Pico and a little bit of coding, you can build your own WiFi controlled car. Here is how to get started.

 

 

Connection Robo Pico and DC Motors

The connection diagram below shows the minimum connection requirement for this lesson.


 

Setting up Your WiFi Connection

Firstly, we need to connect your Raspberry Pi Pico W to the internet by editing the 'setting.toml' file. This file should include your WiFi SSID (the name of your WiFi network), and your WiFi password. Make sure your WiFi is operating at 2.4 GHz, as Raspberry Pi Pico W may have trouble connecting to 5 GHz networks.

 

In the 'setting.toml' file, you will see lines like these:

CIRCUITPY_WIFI_SSID = "YOUR WIFI" 
CIRCUITPY_WIFI_PASSWORD = "YOUR PASSWORD"


Simply replace 'YOUR WIFI' with the name of your WiFi network, and 'YOUR PASSWORD' with your WiFi password.

 


Running Your Car's Control Interface from an HTTP Server

Next, we need to get your car's 'brains' up and running! To do this, you need to download some files from a Github repository and transfer them to your Raspberry Pi Pico W. This code, written in CircuitPython, will tell your car what to do and how to react to your commands.

 

Copy the content of the '05_WiFi_Controlled.py' file and paste it into the 'code.py' file on your Raspberry Pi Pico W. 

 

Once you've done this, you can open up Thonny IDE (a Python development environment), and select the COM port that your Raspberry Pi Pico W is connected to. Then, simply click the 'run' icon at the top of the screen.

 

Once you've clicked 'run', the program will provide a link. You can either click this link directly, or type it into the browser of a mobile phone that's connected to the same WiFi network as your car. This link will lead you to a simple control interface for your new WiFi controlled car.

 

 


Controlling the car is quite simple. If you want to move your car, simply press and hold down the corresponding arrow button on the interface. When you want to stop the car, just release the button. 

 

Here is what the interface will look like in the desktop view.

 

 

And here is what the interface will look like in the mobile view.

 

 

 

Remember, your car's responsiveness depends on your WiFi connection. If there's a delay or lag, it might be due to your WiFi's latency. You can always try using your phone's mobile hotspot for a potentially smoother driving experience. Enjoy the ride!
 

อุปกรณ์ฮาร์ดแวร์