Is it possible to install a second ultrasonic sensor in the starter kit robot?
My idea is to have an ultrasonic sensor at the front and back of the kit so that it has forward and backward “vision”.
Any ideas would be much appreciated. thanks!!
Is it possible to install a second ultrasonic sensor in the starter kit robot?
My idea is to have an ultrasonic sensor at the front and back of the kit so that it has forward and backward “vision”.
Any ideas would be much appreciated. thanks!!
Hi lionbear999,
Yes, that is possible to add extra ultrasonic. The port 4, 6.7.8 on Orion board can be used for the ultrasonic.
Our default program is just a example program for customers to play. It has written port 3 for ultrasonic. You can make your own program to direct the other port to second ultrasonic.
Thank you ever so much for your prompt reply!
I’m new to this so am trying to figure out how to make the two sensors work. Should I use your default program, save as a new file, and change the port to a different port?
For example, I tried to change the port number in the default program (from port 3 to port 4), and got an error in uploading it to the robot.
If you have any tips or ideas, I would be forever grateful.
Thank you
Hi @lionbear999,
to load the example sketch and save under a new name is a good and clever start. Generally, copying and editing existing code is fully ok and helps a lot. We are an open community here, which means we share our work and knowledge and help each other.
You will also need to study the sketch a bit, in order to understand what is going on there. You will recognize that the line which assigns the port also assigns a name to the device (eg “myUltrasonic”). This line you need to duplicate. In the newly created line you change the port to the port where your second ultrasound is connected. You also change the name of it to something more meaningful, e.g. “myBackUltrasonic”.
Then you look at the main loop of the sketch and find out what is done to receive the distances from the original ultrasonic module, and add a similar block to your newly defined, second ultrasonic module. Basically, you will want to duplicate any line where the original ultrasonic sensor is named, and change the name to the new module in the duplicated line.
Use the compile button before you upload. If you made any mistakes in your code, messages will pop up which guide you to the line number where the error occured and you can fix it.
If the messages appear only on upload and if you have the Bluetooth starter kit you need to unplug the cable to the Bluetooth module when you want to upload. Otherwise you will receive an error message and it will not work.
If you get stuck with your knowledge, just copy the sketch and paste it here. Format the pasted sketch as “preformatted text” (</> icon) in this editor here, this makes it easier for us to read it and help you onward.
this is how
your code
looks like
when formatted as
"preformatted text"
Heads-up, you are already on the right track and will dicover great opportunities with these kits.
Stefan
Awesome, thank you very much @srothe for the attention! Your explanation is super clear, and helped me to better understand how it all works. I will implement your suggestions and let you know how it goes.
thank you!