Hello
I have built a model boat with a figure on the fore deck that can rotate the body to the left and to the right and rise his arm and start playing a sound though a loudspeaker. The recorded sound tell ”ship O´hoj”. Greetings to meeting boats. The movements and arm raising is controlled by a Arduino nano. In order to detect meeting boats I have tried different sensors. The one I am now testing is HMMD_mmwave_sensor. it works fine with the enclosure program found on the net.
I intend to use two sensors (one on each side). The program is made in a advanced way and I do not know how to change the program. What I want is catch the calculated distance and save it in order to be able to make a pin HIGH. If I have the the distance i a register I can also use different terms in order to make different things happen related to the distance HIGH pin can then be used to start the figure movements.
Please help me.
Best regards
Åke Silén
Encl.
#include <SoftwareSerial.h>
int val=0;
SoftwareSerial mySerial(5, 4); // RX, TX
void setup() {
// Start the serial communication with a baud rate of 115200
Serial.begin(115200);
mySerial.begin(115200);
// Wait for the serial port to initialize
while (!Serial) {
delay(100);
}
// Hex string to send
String hex_to_send = "FDFCFBFA0800120000006400000004030201";
sendHexData(hex_to_send);
}
void loop() {
// Read and print serial data
readSerialData();
}
void sendHexData(String hexString) {
// Convert hex string to bytes
int hexStringLength = hexString.length();
byte hexBytes[hexStringLength / 2];
for (int i = 0; i < hexStringLength; i += 2) {
hexBytes\[i / 2\] = strtoul(hexString.substring(i, i + 2).c_str(), NULL, 16);
}
// Send bytes through software serial
mySerial.write(hexBytes, sizeof(hexBytes));
}
void readSerialData() {
// Read and print data from software serial
while (mySerial.available() > 0) {
char incomingByte = mySerial.read();
Serial.print(incomingByte);
}
}


