|
1 | 1 | # Install the Code |
2 | 2 |
|
3 | | -Open up Thonny and make sure the rover is turned off. Always be sure to have the battery power off to the Pico before plugging in the USB cable. |
| 3 | +Open up Thonny and make sure the **rover is turned off**. Always be sure to have the battery power off to the Pico before plugging in the USB cable. |
4 | 4 |
|
5 | | -Once the rover is switched off, plug in the USB cable. If Thonny doesn't recognize the Pico, try hitting the STOP button. If that doesn't work try clicking the bottom right to choose the correct device(MicroPyton on Pico). |
| 5 | +Once the rover is switched off, plug in the USB cable. If Thonny doesn't recognize the Pico, try hitting the STOP button. If that doesn't work try clicking the bottom right to choose the correct device : MicroPyton(Raspberry Pi Pico). |
6 | 6 |
|
7 | | -When Thonny detects the Pico, copy the contents from [motor_class.py](https://raw.githubusercontent.com/javaplus/MadScientist/refs/heads/main/code/motor_class.py) into a new/blank Thonny window. |
| 7 | +#### Motor Class |
| 8 | + |
| 9 | +When Thonny detects the Pico, copy the contents from [motor_class.py](https://raw.githubusercontent.com/javaplus/MadScientist/refs/heads/main/code/motor_class.py) into a new/blank Thonny window (File->New). |
8 | 10 | Save this file onto the Pico as `motor_class.py`. |
9 | 11 |
|
| 12 | +#### Hit Event |
| 13 | +Now create a new Thonny tab(File->New) and copy the contents of [hitevent.py](https://raw.githubusercontent.com/javaplus/MadScientist/refs/heads/main/code/hitevent.py) into the new Thonny tab. |
| 14 | +Save this file onto the Pico as `hitevent.py`. |
| 15 | + |
| 16 | +#### Basic Game |
| 17 | +Now create a new Thonny tab and copy the contents of [basicgame.py](https://raw.githubusercontent.com/javaplus/MadScientist/refs/heads/main/code/basicgame.py) into the new Thonny tab. |
| 18 | +Save this file onto the Pico as `basicgame.py`. |
| 19 | + |
| 20 | +#### Main |
| 21 | + |
10 | 22 | Now create a new Thonny tab(File->New) and copy the contents of [main.py](https://raw.githubusercontent.com/javaplus/MadScientist/refs/heads/main/code/main.py) into the new Thonny tab. |
11 | | -Now change the value of the ROVER_NAME variable to be something unique. This will be the bluetooth advertised name of your Rover. Change this to something you can easily remember and unique if doing this with a large group of others. |
| 23 | +Now change the value of the `ROVER_NAME` variable to be something unique. This will be the bluetooth advertised name of your Rover. Change this to something you can easily remember and unique if doing this with a large group of others. |
12 | 24 | Below is the code you need to change... change the "sharkbot1" value to your special name: |
13 | 25 | ```Python |
14 | 26 |
|
15 | 27 | # ROVER_NAME needs to be a unique name for your rover. It will be the advertised bluetooth device name |
16 | 28 | ROVER_NAME = "sharkbot1" |
17 | 29 |
|
18 | 30 | ``` |
19 | | - |
20 | 31 | After changing the ROVER_NAME value, save the code to the Pico as `main.py`. |
21 | 32 |
|
22 | 33 | **Fun Fact**: any code you save into `main.py` at the root of the Pico will run automatically when it's powered up. |
23 | 34 |
|
24 | | -After saving the `main.py` and `motor_class.py` to the Pico, make sure to have the main.py window up in Thonny and click the "Run" button. See if there are any errors in the Shell. |
25 | | -If you see an error about a picozero library or module, be sure to follow these steps to [install picozero onto the Pico](https://picozero.readthedocs.io/en/latest/gettingstarted.html#install-picozero-from-pypi-in-thonny). |
| 35 | +#### Try It Out! |
| 36 | + |
| 37 | +After saving the `motor_class.py`, `hitevent.py`, `basicgame.py`, and `main.py` to the Pico, make sure to have the `main.py` window up in Thonny and click the "Run" button. See if there are any errors in the Shell. |
| 38 | +If you see an error about a **picozero** library or module, be sure to follow these steps to [install picozero onto the Pico](https://picozero.readthedocs.io/en/latest/gettingstarted.html#install-picozero-from-pypi-in-thonny). |
| 39 | + |
| 40 | +If you there are no errors, it's time to test it out! |
| 41 | + |
| 42 | +Since testing it out means using the mad scientist app to control the motors, you may want to lift the Rover off the ground while connected to the USB cable. You can use one of the included clear dixie cups upside down under the Rover to keep the tracks off the ground. |
| 43 | + |
| 44 | + |
| 45 | + Now open the mad scientist app and connect to the Rover. Be sure to keep the power switch off on the Rover. |
26 | 46 |
|
27 | | -If you see no errors, try to use the mad scientist app to connect to the Rover. Be sure to keep the power switch off on the Rover. |
28 | 47 | When the RGB eyes are flashing blue, that means the rover is advertising and waiting for a bluetooth connection. |
29 | | -In the mad scientist app, type in the value you put for the ROVER_NAME variable to make it easier to find your rover and then hit `CONNECT`. |
| 48 | +In the mad scientist app, type in the value you put for the `ROVER_NAME` variable to make it easier to find your rover and then hit `CONNECT`. |
| 49 | + |
| 50 | +When the app is connected to the Rover, the eyes should turn green. Now try to move the joystick in the app to test the motor control is working. If any of the movement is reversed, you can simply go to the settings menu of the app and reverse the controls. |
| 51 | + |
| 52 | + |
30 | 53 |
|
0 commit comments