Hi There.
I'm new to all this Arduino and programming stuf, so this might seam as a stupid question, so sorry in advance ![]()
Anyways here is what I am trying to do :
I have a program called "Picolog" that interfaces to some specific hardware, instead of using the specific hardware I want to use the arduino to send a value.
My problem is that the value has to be sent in HEX, and has to start with 2D then followed by XX XX ( XX XX Being the values)
Below is my code so far :
int incomingByte = 0; // for incoming serial data
int pin = 7;
unsigned long duration;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(pin, INPUT);
}
void loop() {
duration = pulseIn(pin, HIGH);
// send data only when you receive data:
if (Serial.available() >0) {
// read the incoming byte:
incomingByte = Serial.read();
if (incomingByte == 0x01){
Serial.write(0x10);
Serial.write(0x0a);
}
if (incomingByte == 0x1F || incomingByte == 0x97){
}
}
}
So far in the section :
if (incomingByte == 0x01){
Serial.write(0x10);
Serial.write(0x0a);
}
I have it working as the program I'm using needs a reply of HEX "10 0a", and this is what I am sending.
But now comes the tricky part and where I get lost.
I now need to get the value from "duration" sent as a hex value, but starting with 2D in HEX, so that when looking at it the transmitted data looks like this ( 2D FF FF) The FF is only a example.
Hope the above is usefull, and that someone can help me, I am lost and need this badly for a test...

