Hi I try first the read of the value but only get Bullshit
To be honest i am new to arduino and have no real idea.
For receiving, I just look for a rising edge on the DHSG line, wait 0.3125ms and then read the PIN state every 0.625ms to include the zeroes , first i just want to write to serial for checking if working and later I want to write to a buffer and check whether the result matches a valid DHSG code.
After this i want to set up a timer for 1600 Hz and alternately transmit one data bit and a zero bit when the interrupt fires to send a DHSG message.
int buttonStateRising = 1;
int lastButtonStateRising = 1;
int i;
void setup() {
Serial.begin(9600);
pinMode(11, INPUT);
}
void loop() {
buttonStateRising = digitalRead(11);
if ((buttonStateRising == HIGH) && (lastButtonStateRising == LOW)) {
Serial.println("There was a rising edge on pin 11");
delay(0.325);
for (i=0; i<7 ; i++){
if (digitalRead(11) == HIGH){
Serial.println(1);
} else {
Serial.println(0);
}
delay(0.625);
}
}
lastButtonStateRising = buttonStateRising;
}
umarr: without even understanding what you want to do, looking at your code, I believe you can not have a delay that is fractional. The delay expects a datatype of long integer, so no floating point value.
Amazingly, I tried placing a delay(0.625) in some code and the compiler doesn't complain, and I didn't look too closely why it wouldn't, or even what the result would be, except that it would probably equate to zero, so a delay of zero time, which will not be what you want, correct ?
Anyhow, if you want smaller delays than milliseconds then use this code:delayMicroseconds(625);
Most of the information i found was with a Clock Line but the DHSG connector has only BUS Send and BUS Receive.
Bit-banging is more common on synchronous interfaces but there are several examples that do it asynchronously: SoftwareSerial (bad example), AltSoftSerial (much better example, but much more complex code) or the WS2812 driver.
If you do it like SoftwareSerial, you're blocked during sending (so also no reception possible during that time) and receiving. The other examples use hardware timers to do the job which doesn't let the processor wait for such long time frames but the programming needs more inside know-how and is very hardware dependent.