Index>Robot Kit>Mars Rover PiCar-B Smart Robot Car Kit for RPi>Lesson 4 How to View or Edit the Code Program in Raspberry Pi

Lesson 4 How to View or Edit the Code Program in Raspberry Pi

1127

Lesson 4 How to View or Edit the Code Program in Raspberry Pi

 

To make daily use of the Raspberry Pi more convenient, we usually do not connect peripherals such as mouse, keyboard, and monitor to the Raspberry Pi. Since our Raspberry Pi is installed inside the robot, often with peripherals to control the Raspberry Pi, the efficiency of programming and testing will be seriously affected. Therefore, we introduce a method of programming in the Raspberry Pi.

 

4.1 For Mac

 

A third-party software Putty will be used for this method. For detailed instructions, refer to 3.6.2 Remotely logging in to the Raspberry Pi system.

Putty is a terminal software to remotely control Raspberry Pi (need to enable SSH).

Operation Steps

1. Run Putty, type in the IP address of your Raspberry Pi and click open. Enter your user name and password – with the initial user name: pi, password: raspberry.

2. Type in "ls" to show the files to be edited or viewed.

image.png 

3. Type in "sudo nano <file path>" to view or edit a file, as shown below:

sudo nano adeept_picar-b/server/RGB.py

image.png 

image.png 

4. Exit. Press Ctrl + X on your keyboard to exit if nothing is changed. Otherwise press Y and Enter key to save and exit.

4.2 For Windows

 

A third-party software MobaXterm will be used for this method. For detailed instructions, refer to 3.6.2 Remotely logging in to the Raspberry Pi system.

MobaXterm is a terminal software to remotely control Raspberry Pi (need to enable SSH).

To run MobaXterm, firstly, create a new session, click Session in the upper left corner, click SSH in the pop-up window, fill in the IP address of the Raspberry Pi behind Remote host, and finally click OK, the default account name of the Raspberry Pi is pi , The default password is raspberry. Just the password doesn't appear on the screen when you enter it and the * number doesn't mean nothing Enter successfully, press after login to log in to the Raspberry Pi, MobaXterm will remind you to save the password.You need to choose.

image.png 

If the user name and password are correct, you can change the user name and password according to the prompt in the terminal, which is more secure.

After the success of the login, MobaXterm will automatically save the conversation, when connected to the raspberry pie again next time only need to double click on the left side of the IP address can be connected to the Raspberry Pi again, if there is no save username and password will need to input the user name and password, if the IP address of the Raspberry Pi changed, you need to start a new dialogue.

After a successful login, the left column is replaced with a file transfer system, which allows you to interact with the system inside the Raspberry Pi. If you want to return to session selection, just click Sessions.

Programs you write on other devices can be transferred to the Raspberry Pi by simple drag and drop, and then the Raspberry Pi can be controlled in the terminal to execute the program, or the files in the raspberry Pi can be dragged to other devices.

If you want to use another IDE to edit files in Raspberry Pi, you can find the file you want to edit in the file transfer system on the left side of the MobaXterm. Right-click on this file and select your IDE so you can use your favorite on other devices IDE to edit the Raspberry Pi file, after editing, press "CTRL+S" to save the file and it will be automatically synchronized to the Raspberry Pi. image.pngimage.png

However, it should be noted that when you use MobaXterm's file transfer system to edit files in the Raspberry Pi, you need to pay attention to the permissions problem, because the file transfer system does not have root permissions, so if you are prompted to save after editing the file The permission denied error causes the file cannot be saved after editing. You need to use the following command to give the file you want to edit permission to be edited by MobaXterm:

sudo chmod 777 [FileName]  , For example:

sudo chmod 777 adeept_picar-b/server/RGB.py

Give permissions, where *** is the Linux permission code, we do not recommend the use of permissions such as 777, but for novices 777 can avoid many account and permissions problems, of course, you can also set it to 700 , So that only the owner can read, write and execute. You can learn more about Linux permissions through maketecheasier article from the article link

https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means

If you encounter any problems, please contact us: support@adeept.com