I will write about the preparation for running ev3 in Java.
A system that provides a Java programming environment for LEGO Mindstorms robots.
This time, I will run ev3 on ** Mac OS X ** using ** bluetooth **. In addition, a program is created and processed using ** Eclipse **, which is a Java integrated development environment.
◯ ev3 (tank) ◯ Personal computer (Eclipse) ◯ bluetooth ◯ microSD ◯ leJOS-API
I think it's best to read this article and proceed.
[LeJOS] Let's program mindstorm-EV3 in Java [Environment construction first part] [LeJOS] Let's program mindstorm-EV3 in Java [Environment construction part 2]
** 1 **. Download the latest from sourceforge / lejos ev3.
** 2 **. Unzip the downloaded one → Unzip sd500.zip.
** 3 **. Use Ethcher to write sd500.img to the sd card.
** 4 **. Unzip lejosimage.zip → Write all the files inside to the SD card. (Drag and drop to move the file to the root directory (top level space) of the SD card.)
** 5 **. Download Java for lejos from Oracle JRE.
** 6 **. Move the downloaded file to the root directory (top level space) of the SD card as it is.
** 7 **. Insert the SD card into ev3 and boot.
@ev3-brick
** 1 **. Select PAN ** 2 **. Select BT Client ** 3 **. Select the computer you want to connect to ** 4 **. Successful connection when IP address is displayed
◯ It is not necessary to execute a general program. Please do it when you need it.
@Terminal
** 1 **. Enter root @ 192. ~. ~. ~
** 2 ** .Enter key
** 3 **. Confirmation If successful, it will look like ↓ root@EV3:~#
** Edit the config file with a vi editor **.
@Terminal
** 1 **. Type cd / etc
** 2 ** .Check if there is a .config file Type `ʻopen ssh``
** 3 **. Access the .config file
cd ssh
sudo vi ssh_config
Enter your computer password
** 4 ** Edit with .vi editor
Press the i key (INSERT = command to enter characters)
Add the following code at the bottom
Host 10.0.1.1 192.~.~.~ KexAlgorithms +diffie-hellman-group1-sha1 Ciphers aes128-cbc
Press esc
Press the :
key
Type wq
(command to save and exit)
Press enter
** 5 **. Check connection
ssh root@192.~.~.~
[Reference article] Lego EV3 Tutorial with leJOS on macOS How to use the vi command
It is very easy to understand, so please refer to this. [LeJOS] Let's program mindstorm-EV3 in Java [Environment construction part 2]
◯ Sample code example
//Import the required code
import lejos.hardware.*;
//Create a class
public class HelloWorld
{
//Create a static method
public static void main(String[] args)
{
//Hello World!!And output to the screen of ev3
System.out.println("Hello World!!");
//Wait until any button is pressed
Button.waitForAnyPress();
}
}
Thank you for reading. Next time, I would like to write about the control of a single motor. If you find any mistakes or improvements, please let us know.
Recommended Posts