background image

SunFounder pico_4wd_car

www.sunfounder.com

Sep 21, 2022

Summary of Contents for Pico-4wd car

Page 1: ...SunFounder pico_4wd_car www sunfounder com Sep 21 2022 ...

Page 2: ......

Page 3: ...e Car 25 1 6 6 Examples 25 2 Appendix 53 2 1 Introduction to Raspberry Pi Pico 53 2 2 Introduction to Pico RDP 55 2 3 Schematic and Structure Drawing 56 2 4 Thonny IDE Introduction 57 3 FAQ 59 3 1 Q1 NO MicroPython Raspberry Pi Pico Interpreter Option on Thonny IDE 59 3 2 Q2 Cannot open Pico code or save code to Pico via Thonny IDE 60 4 Thank You 61 5 Copyright Notice 63 i ...

Page 4: ...ii ...

Page 5: ...uickly In addition you can also use an app SunFounder Controller to DIY your own control methods Let s Play Here is the Email cs sunfounder com About the display language In addition to English we are working on other languages for this course Please contact service sunfounder com if you are interested in helping and we will give you a free product in return In the meantime we recommend using Goog...

Page 6: ...ico_4wd_car There will be a language popup in the upper right corner Click on the menu button to choose another language Select the language from the inverted triangle box and then click Done Source Code 2 CONTENTS ...

Page 7: ...SunFounder pico_4wd_car SunFounder Pico 4wd Car Code Or check out the code at CONTENTS 3 ...

Page 8: ...SunFounder pico_4wd_car 4 CONTENTS ...

Page 9: ...u re ready to learn programming Note Since the Raspberry Pi Pico interpreter only works with Thonny version 3 3 3 or later you can skip this chapter if you have it otherwise please update or install it 1 You can download it by visiting the website Once open the page you will see a light gray box in the upper right corner click on the link that applies to your operating system 2 The installers have...

Page 10: ...SunFounder pico_4wd_car 3 Next click Next and Install to finish installing Thonny 6 Chapter 1 Get Started ...

Page 11: ...ractive prompt the REPL to execute supported commands immediately Included are a selection of core Python libraries MicroPython includes modules which give the programmer access to low level hardware Reference Now come to install MicroPython into Raspberry Pi Pico Thonny IDE provides a very convenient way for you to install it with one click Note If you do not wish to upgrade Thonny you can use th...

Page 12: ...ro USB cable Release the BOOTSEL button after your Pico is mount as a Mass Storage Device called RPI RP2 3 In the bottom right corner click the interpreter selection button and select Install Micropython Note If your Thonny does not have this option please update to the latest version 8 Chapter 1 Get Started ...

Page 13: ...r pico_4wd_car 4 In the Target volume the volume of the Pico you just plugged in will automatically appear and in the Mi cropython variant select Raspberry Pi Pico Pico H 1 2 2 Install MicroPython on Your Pico 9 ...

Page 14: ...SunFounder pico_4wd_car 5 Click the Install button wait for the installation to complete and then close this page 10 Chapter 1 Get Started ...

Page 15: ...ou need to upload its related libraries in Raspberry Pi Pico 1 Download the relevant code from the link below SunFounder Pico 4wd Car Code 2 Open Thonny IDE and plug the Pico into your computer with a micro USB cable and click on the MicroPython Raspberry Pi Pico COMXX interpreter in the bottom right corner 1 3 3 Upload the Libraries to Pico 11 ...

Page 16: ...r pico_4wd_car 3 In the top navigation bar click View Files 4 Switch the path to the folder where you downloaded the code package before and then go to the pico_4wd_car_main libs folder 12 Chapter 1 Get Started ...

Page 17: ...o_4wd_car 5 Select these 3 files right click and click Upload to it will take a while to upload 6 Now you will see the files you just uploaded inside your drive Raspberry Pi Pico 1 3 3 Upload the Libraries to Pico 13 ...

Page 18: ...y testing of the modules before assembly or for final commissioning and mainte nance of the Pico 4wd after assembly has been completed 1 4 1 Power up the Pico RDP In order to make the module work you need to power up the Pico RDP and turn the power switch to ON 14 Chapter 1 Get Started ...

Page 19: ...m below 2 Select Correct Interpreter Plug the Pico into your computer with a micro USB cable and select the MicroPython Raspberry Pi Pico COMXX interpreter in the bottom right corner 3 Go to the pico_4wd_car_main tests path and double click on test_motor py to open it 1 4 4 Test the Modules 15 ...

Page 20: ...t script button or just press F5 to run it Now you can see the four motors work in a regular pattern If you complete the assembly this code will make the Pico 4wd perform five movements forward backward left right and stop 16 Chapter 1 Get Started ...

Page 21: ...SunFounder pico_4wd_car 1 4 3 Test the Ultrasonic Module 1 Connect the ultrasonic module as shown below 2 Run the test_sonar py file under the path pico_4wd_car_main tests 1 4 4 Test the Modules 17 ...

Page 22: ...will be displayed in the Shell If the distance changes when your hand is in front of the ultrasonic module the module is working properly 1 4 4 Test the RGB Boards 1 As shown below connect the 3 RGB boards 2 Run the test_light py file in pico_4wd_car_main tests 18 Chapter 1 Get Started ...

Page 23: ... After the code is run the 24 LEDs all on the 3 RGB boards to emit red green blue and white light in turn 1 4 5 Test the Grayscale Sensor Module 1 Diagrammatically connect the Grayscale Sensor Module 1 4 4 Test the Modules 19 ...

Page 24: ...SunFounder pico_4wd_car 2 Run the test_grayscale py file in pico_4wd_car_main tests 20 Chapter 1 Get Started ...

Page 25: ...ontrast may not be suitable for your current environment which means the grayscale module cannot identify white and black lines well so it needs to be calibrated Tape a small piece of black electrical tape to the ground or table Hold the grayscale module 1 cm above the table this is about the same height as after assembly so you can use it directly after calibration Keep test_grayscale py running ...

Page 26: ...below to connect the Speed Module 2 Run the test_speed py file in pico_4wd_car_main tests Note The Thonny IDE contains a line graph tool please open it by clicking View Plotter in the navigation bar to help you see how the printed values are changing 22 Chapter 1 Get Started ...

Page 27: ... print the current speed If you have already mounted it this code will make the Pico 4wd move forward at variable speed and print out the motor power as a percentage and the travel speed cm s To use it you should hover the car so that the motor rotation is not obstructed 1 4 7 Test the Servo 1 Connect the servo according to the following diagram 1 4 4 Test the Modules 23 ...

Page 28: ...the test_servo py file in pico_4wd_car_main tests Insert a rocker arm first to observe the rotation of the servo After clicking on the Run button the servo will rotate left and right once and then stop at 0 24 Chapter 1 Get Started ...

Page 29: ...o assemble PDF Pico 4wd Assemble Instruction 1 6 6 Examples Here are some interesting and useful Pico 4wd projects you can follow the tutorials to accomplish The flowcharts in each examples and the documentation can help you better understand the internal programming principles 1 6 1 Motor Calibration Because of assembly methods and other reasons your motor may still need a calibration direction O...

Page 30: ...n it This is a very simple example which will let the car go forward 3 Observe whether the wheels of the car are driving forward and marked the wrong motor 4 Open the pico_4wd py file that was uploaded to the pico before modify the wrong motor s dir to reverse the value and save it 26 Chapter 1 Get Started ...

Page 31: ...SunFounder pico_4wd_car 5 Run again move_forward py if the car is driving correctly the calibration is completed 1 6 6 Examples 27 ...

Page 32: ...the cliff In this example the car will be dormant If you push it to a cliff it will be awakened urgently then back up and shake its head to express dissatisfaction How to do 1 Select Correct Interpreter Plug the Pico into your computer with a micro USB cable and select the MicroPython Raspberry Pi Pico COMXX interpreter in the bottom right corner 28 Chapter 1 Get Started ...

Page 33: ...SunFounder pico_4wd_car 2 Go to the pico_4wd_car_main examples path and double click on donot_push_me py to open it 3 Click the Run current script button or just press F5 to run it 1 6 6 Examples 29 ...

Page 34: ... values are below 1000 then it should be considered a cliff and can move backward This threshold can be obtained in the Test the Grayscale Sensor Module section for example in my test the detected cliff value is basically around 700 so here it is set to 1000 as long as it is lower than 1000 it can be considered to detect a cliff 4 To enable Pico 4wd to run this code on boot you need to save donot_...

Page 35: ...SunFounder pico_4wd_car Select Raspberry Pi Pico in the popup window that appears Set the file name to main py 1 6 6 Examples 31 ...

Page 36: ...ar After clicking OK the Raspberry Pi Pico will have an additional main py file Afterwards you can unplug the USB cable turn on the power switch on the car and the script main py will begin running 32 Chapter 1 Get Started ...

Page 37: ...SunFounder pico_4wd_car How it Work 1 6 6 Examples 33 ...

Page 38: ...d or table with black insulating tape Run this script and you will see Pico 4wd track the line to forward Warning When pasting this line there should be no sharp turns so that the car does not drive off the path How to do 1 Open the line_track py file under the path of pico_4wd_car_main examples 34 Chapter 1 Get Started ...

Page 39: ...xample in my tests black surfaces generally around 3000 and white surfaces are around 20000 so 10000 is the appropriate threshold value According to the actual situation you can modify it to other values according to the actual situation car GRAYSCALE_LINE_REFERENCE 10000 3 Click File Save as or press Ctrl Shift S and then select Raspberry Pi Pico in the popup window that appears 1 6 6 Examples 35...

Page 40: ...e to main py If you already have the main py file in your Pico it will prompt to overwrite the main py file Now you can unplug the USB cable place the car on the taped line turn on the power switch and it will track the 36 Chapter 1 Get Started ...

Page 41: ...hting effects when the Pico 4wd is going straight the taillight the RGB panel on the tail will light up green when turning one side of the taillight will light up yellow During sharp turns one side of the taillight will light up red How it Works 1 6 6 Examples 37 ...

Page 42: ...Founder pico_4wd_car 1 6 4 Follow Your Hand Here Pico 4wd will follow your hand moving forward How to do 1 Open the follow_hand py file under the path of pico_4wd_car_main examples 38 Chapter 1 Get Started ...

Page 43: ...2 Click File Save as or press Ctrl Shift S to save donot_push_me py to the Raspberry Pi Pico as main py 3 Unplug the USB cable and turn on the power switch When you put your hand in front of it it will follow 1 6 6 Examples 39 ...

Page 44: ...SunFounder pico_4wd_car How it works 40 Chapter 1 Get Started ...

Page 45: ...task automatically avoid obstacles When an obstacle is detected instead of simply backing up the radar scans the surrounding area and finds the widest way to move forward How to do 1 Open the obstacle_avoid py file under the path of pico_4wd_car_main examples 1 6 6 Examples 41 ...

Page 46: ...Save as or press Ctrl Shift S to save donot_push_me py to the Raspberry Pi Pico as main py 3 Unplug the USB cable and turn on the power switch When you place it on the ground it avoids the obstacles and keeps going 42 Chapter 1 Get Started ...

Page 47: ...ilding a remote project using the Sunfounder Controller APP which means you can use your phone tablet to control your Pico 4wd car 1 Setup SunFounder Controller 1 Install APP from APP Store iOS or Google Play Android 2 Open SunFounder Controller and click on the to create a new controller 1 6 6 Examples 43 ...

Page 48: ...SunFounder pico_4wd_car 3 We have preset controller for Pico 4wd you can choose it directly 4 Define a name for this Controller and click Confirm 44 Chapter 1 Get Started ...

Page 49: ...de this preset controller click the Grayscale Values widget s Settings button to change its reference value 6 The following thresholds should be modified based on the values obtained in the Test the Grayscale Sensor Module section 1 6 6 Examples 45 ...

Page 50: ...nges click the Edit button again 2 Make the app_control py file run on boot In order for Pico 4wd to be able to run specific scripts without being connected to a computer and then be controlled by SunFounder Controller You need to save the specific script to the Raspberry Pi Pico with the name main py as follows 46 Chapter 1 Get Started ...

Page 51: ...it as it may be used to connect to SunFounder Controller later on 3 Stop the script from running and click File Save as or press Ctrl Shift S then select Raspberry Pi Pico in the popup window that appears If this pop up does not appear on yours make sure you have plugged the Pico into your computer with a micro USB cable and select the MicroPython Raspberry Pi Pico COMXX interpreter in the bottom ...

Page 52: ...will prompt to overwrite it Now you can unplug the USB cable turn on the power switch of Pico 4wd and Pico 4wd will automatically run this main py script 3 Connect to Pico 4WD car 1 Find my_4wd_car on the WLAN of the mobile phone tablet enter the password 12345678 and connect to it 48 Chapter 1 Get Started ...

Page 53: ...fter you connect there will be a prompt telling you that there is no Internet access on this WLAN network please choose to continue connecting 3 Now go back to SunFounder Controller when you click the Connect button it will automatically search for robots nearby 1 6 6 Examples 49 ...

Page 54: ...re that your mobile device is connected to the my_4wd_car LAN If it doesn t search automatically you can also manually enter your car s IP to connect Once you click on my_4wd_car the message Connected Successfully will appear and the product name will 50 Chapter 1 Get Started ...

Page 55: ...et the A widget to 30 or more B The display of the car moving speed unit cm s C Display of car speed in digital format D Radar display of obstacles detected by ultrasonic module G Turn on off WS2812 RGB board H Show the data of the three sensors on the grayscale module which have three states black block black line detected white white detected exclamation point cliff detected K Control forward ba...

Page 56: ...SunFounder pico_4wd_car 52 Chapter 1 Get Started ...

Page 57: ...mmunity will support you every step of the way In the project it can control anything from LEDs and buttons to sensors motors and even other microcontrollers Features 21 mm 51 mm form factor RP2040 microcontroller chip designed by Raspberry Pi in the UK Dual core Arm Cortex M0 processor flexible clock running up to 133 MHz 264KB on chip SRAM 2MB on board QSPI Flash 26 multifunction GPIO pins inclu...

Page 58: ...sed as an analog input as well as a digital input or output but not both at the same time ADC_VREF Analog to digital converter ADC voltage reference A special input pin which sets a reference voltage for any ana log inputs AGND Analog to digital converter ADC 0 volts ground A special ground connection for use with the ADC_VREF pin 3V3 O 3 3 volts power A source of 3 3V power the same voltage your ...

Page 59: ...ent It also has IO expansion interface circuitry LED power indicator circuitry voltage measurement circuitry and an on board 4 channel DC motor driver circuit When you use Pico RDP for development and debugging you can connect peripherals as needed and the rich external interfaces can make your projects more interesting Features Microcontroller Raspberry Pi Pico module Wi Fi ESP8266 Wi Fi module 8...

Page 60: ... is the schematic of the Pico RDP PDF Pico RDP Schematic 2 3 Schematic and Structure Drawing Schematic Grayscale Module RGB Board Pico RDP Speed Module Structure Drawing Lower Plate Upper Plate The Whole Car 56 Chapter 2 Appendix ...

Page 61: ... to the Raspberry Pi Pico E The play icon allows you to run the code If you have not saved the code save the code before it can run F The Debug icon allows you to debug your code Inevitably you will encounter errors when writing code Errors can take many forms sometimes using incorrect syntax sometimes incorrect logic Debugging is the tool for finding and investigating errors Note The Debug tool c...

Page 62: ...lick it to return from debug mode to play mode K Use the stop icon to stop running code L Script Area where you can write your Python code M Python Shell where you can type a single command and when you press the Enter key the single command will run and provide information about the running program This is also known as REPL which means Read Evaluate Print and Loop N Interpreter where the current...

Page 63: ...our computer via a USB cable Check that you have installed MicroPython for Pico 2 Install MicroPython on Your Pico The Raspberry Pi Pico interpreter is only available in version 3 3 3 or higher version of Thonny If you are running an older version please update 1 Install Thonny IDE Plug in out the micro USB cable sveral times 59 ...

Page 64: ...3 2 Q2 Cannot open Pico code or save code to Pico via Thonny IDE Check that your Pico is plugged into your computer via a USB cable Check that you have selected the Interpreter as MicroPython Raspberry Pi Pico 60 Chapter 3 FAQ ...

Page 65: ... users who have been following and supporting us Your valuable suggestions to us are our motivation to provide better products Particular Thanks Len Davisson Kalen Daniel Juan Delacosta Now could you spare a little time to fill out this questionnaire Note After submitting the questionnaire please go back to the top to view the results 61 ...

Page 66: ...SunFounder pico_4wd_car 62 Chapter 4 Thank You ...

Page 67: ... it for personal study investigation enjoyment or other non commercial or nonprofit purposes under therelated regulations and copyrights laws without infringing the legal rights of the author and relevant right holders For any individual or organization that uses these for commercial profit without permission the Company reserves the right to take legal action 63 ...

Reviews: