Ozeki Matrix Ultrasonic Control Code
Ultrasonic sensors measure distance with ultrasonic waves. It measures timeframe from emitting sound until receiving the rebounced soundwaves. By knowing the soundspeed (340.29m/s), the ultrasonic controller can calculate the distance in 0.01cm accuracy. You can always ask the current distance between any object and the sensor. This a perfect tool for building small robots.
Required hardware
- Ozeki Ultrasonic Module
- Ultrasonic sensor(s)
Source code to install on controller
Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h> #include <OzUltraSonicSensor.h> // global pointers OzIDManager* manager; OzUltraSonicSensor* ultraSonicSensor_01; OzUltraSonicSensor* ultraSonicSensor_02; OzUltraSonicSensor* ultraSonicSensor_03; OzUltraSonicSensor* ultraSonicSensor_04; const int triggerPin_01 = 14; const int echoPin_01 = 15; const int triggerPin_02 = 4; const int echoPin_02 = 2; const int triggerPin_03 = 5; const int echoPin_03 = 3; const int triggerPin_04 = 8; const int echoPin_04 = 9; void setup() { Serial.begin(115200); manager = new OzIDManager; manager->_sendACK = true; manager->_checksum = true; OzCommunication::setIDManager(manager); ultraSonicSensor_01 = new OzUltraSonicSensor(triggerPin_01, echoPin_01); ultraSonicSensor_02 = new OzUltraSonicSensor(triggerPin_02, echoPin_02); ultraSonicSensor_03 = new OzUltraSonicSensor(triggerPin_03, echoPin_03); ultraSonicSensor_04 = new OzUltraSonicSensor(triggerPin_04, echoPin_04); int x=1; manager->sendLinkSetup(); manager->PrintWelcomeLine(ultraSonicSensor_01, x++, "Ultra_1"); manager->PrintWelcomeLine(ultraSonicSensor_02, x++, "Ultra_2"); manager->PrintWelcomeLine(ultraSonicSensor_03, x++, "Ultra_3"); manager->PrintWelcomeLine(ultraSonicSensor_04, x++, "Ultra_4"); Serial.println("c=welcome&type=OzMatrixUltraSonic&id=OZMULT"); } void loop() { ultraSonicSensor_01->ownLoop(); ultraSonicSensor_02->ownLoop(); ultraSonicSensor_03->ownLoop(); ultraSonicSensor_04->ownLoop(); OzCommunication::communicate(); }
More information
- How to setup a ultrasonic sensor on arduino mega
- How to setup a ultrasonic sensor on arduino nano
- How to setup a ultrasonic sensor on arduino uno
- How to setup a ultrasonic sensor on Ozeki matrix
- How to setup a ultrasonic sensor on Raspberry Pi
- Ultrasonic sensor protocol for arduino
- How to control an ultrasonic sensor using chat messages
- Ultrasonic Desc
- Ultrasonic Arduino
- Ultrasonic Matrix Arduino