Based on a request from Abdulah we decided to build a tutorial on how to use Hi Technic Color Sensor and EV3-G Software. There is a special block imported in the software that helps you use the sensor.
- 26 Jul 2015
Hi Technic Color Sensor was mainly used with NXT version of LEGO Mindstorms robots. The sensor was quite powerful with a number of modes in which it could work. As the EV3-G version of Mindstorms became available a special block was builded. The block could be downloaded from the Hi Technic site.
In the video we are exploring a simple line following with the sensors.
Note: As of building the video we do not have the sensor. It seems to be out of stock. So we have not actually tested the program, but it is following a working algorithm and should work :)
- Last week we got the question, "How can we use the HiTechnic Color sensor in the EV3 software?" We found out that there is a block for this, and today we are exploring how can we work with this block. First, you have to download the HiTechnic EV3 Color sensor block. You can do this from the HiTechnic site. Go to Downloads, and from Downloads, you choose Mindstorms EV3 Programming Blocks. And from there, at the bottom, you see the HiTechnic EV3 Color sensor block. Now you download this. It's a ZIP. And you save it, for example, somewhere on your computer. Then you open the EV3 software, and you go to Tools, Block Import Wizard. Now, I've already imported this block in my software, but if this is your first time, you'll click Browse. You find the the folder where you extracted the ZIP file. And in this folder you see a file called HT Color EV3 B from Block. You select it, Open, Import, and on your side here at this step, it will just import in my case. Because the block is already existing, it says that it has to override it. I don't want to override the block. And then you restart the software. After you restart the software, you have one new block in your sensors section. This is the HiTechnic Color block. Now the question that we received is, "How do you follow a line with this sensor?" As you can see, this sensor can measure color. It can measure an RGB value. It can measure a raw value. And one of the very, very, very simple ways to follow a line is to follow a line by moving the motor two states. It is a simple program that goes like this. In the loop, we measure with the color sensor, the color that the sensor detects. If the color is black, we move one of the motors for an unlimited amount; for example, Motor D. And if the sensor detects white, another color, we move another motor; for example, Motor C. This is, of course, if we have Motor D and C as primary motors. One more modification here, everything we switch from black to white and from white to black, we switch the motors. So when we are over black, we have Motor D moving. When we are over white, we have Motor C moving. And we must also stop the opposite motor in the opposite case. So here, we stop Motor C. We turn off Motor C. And here, we turn off Motor D. Again, this here is the color sensor. It is not the HiTechnic Color sensor; it is the standard EV3 color sensor. And when it detects black, we stop Motor C and we start Motor D. When it detects white, we stop Motor D and we start Motor C, and you get this zig-zag movement, most of the people working with Mindstorms are very familiar because this is the simplest way to follow a line. You have two states, only two states, and in these two states, you switch between the states and you move from left to right and you actually follow the border between the line and the field. Now the question is, "How do we do this with the HiTechnic sensor?" Unfortunately, we don't have a HiTechnic sensor currently, so we cannot experiment with this. That's why we are only guessing on how it should work, and I welcome any comments on whether this program actually works when you download it to your software, to your . We follow the same principle. So, the color sensor, again, returns a color, and it's a number. So, as you can see, the HiTechnic Color sensor, it can measure color and it returns a number. And this number, if I assume that for black we have, let's say, 10, or for white, we have 20, or 1 or 2, and we have different numbers for the different colors. I don't know what are the numbers for the different colors, but I'm sure that for different colors, we get different numbers, which is basically the case here, different colors black, different color white. Now if we make this switch not dependent on the color sensor but on number, we can just implement the with the HiTechnic sensor as we take an input from the HiTechnic Color sensor. And then, if the HiTechnic Color sensor returns one, let's say that this is black, we again stop Motor C, start Motor D. If it returns white, which is let's say 6, we stop Motor D, we start Motor C. And this is I assume, again we don't have the sensor so that we can test it, I welcome any comments if you can test it and say whether it works, but this is a very, very simple way to follow a line with the HiTechnic Color sensor in the EV3 software. There are also other ways, which we will probably explore when we are able to have this sensor with us so that we can experiment this, but we also can measure an RGB, we can measure , which would probably give us more details on what exactly is the color underneath the sensor. And we'll probably have a smoother [[00;7:21]]. Again, you can find this program below in the materials.