Guest Post by Toni Norrell | Getting Started with the Ultrasonic Ranger (with the Innovator Hub)

A great post from Math & Computer Science guru Toni Norrell (@ToniNorrell).

Michelle & I wanted to explore using the Ultrasonic Ranger with the Innovator Hub for a presentation we were putting together. We started off by focusing on the syntax needed to connect the ranger to collect a distance measurement. This consisted of several lines of code in the screenshot shown below.

Send “CONNECT RANGER 1 TO IN 1” is the initial code that connects the ranger (named RANGER 1) to the hub digitally. Physically, the ranger is connected in the port IN 1 on the side of the Innovator hub. The commands Send “CONNECT RANGER are found under the hub menu (Send “CONNECT -Input), TO is found in the hub menu under settings, and IN 1 is found under the hub menu and Ports.

Once the ranger is connected, we want to send a command to read this device called RANGER 1 using the command Send “READ RANGER 1” . The “READ” command tells the Ranger to “read” the distance at that particular instance in time. So far, we have connected the ranger, and read the ranger, but we haven’t done anything with that reading. Our next statement Get distance, will actually get the reading and then store it in a variable named distance. Of course, we won’t see this value unless we use the display command to show us the output: Disp distance. Note: The display command is not necessary for the data collection to work, however, it is a nice feature that allows us to get that visual check to see if our program is recording and saving distances.

It is good practice to use the last line of code which is Send “DISCONNECT RANGER 1” which is found under the hub menu. On the next post, Michelle will address the warm_up() statement in the code.

Here’s a short video showing this program in action. Also, you can download a copy of the TNS file for this short program.

Toni Signature

 

2 thoughts on “Guest Post by Toni Norrell | Getting Started with the Ultrasonic Ranger (with the Innovator Hub)

Share your thinking...!