Hello, I'm trying to set a input pin of my arduino as a simple trigger to send a push notification to my phone. I have read the blueiris documentation but it's seems unclear as to why my code isn't working. I tried sending 1 in ASCII through the serial, I tried sending the binary value 1 and at last I tried the global_input_dio_bits code below but blueiris doesn't react or show the active input in the setting page.
Code:
/ PIN 7 = D4
#define DB_PIN 4
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
pinMode(DB_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
bool switchStatus = dbPressed();
if (switchStatus) {
sendBlueIrisByte(1);
digitalWrite(LED_BUILTIN, HIGH);
/ This doesn't stop blue iris recording, but does tell blue iris to be
/ ready for the next trigger.
delay(10);
resetBlueIrisByte();
delay(2000);
digitalWrite(LED_BUILTIN, LOW);
}
}
/ Blue Iris accepts a number called "Global input dio bits" to trigger a
/ camera. This function converts the input number into a bitwise number,
/ the format Blue Iris expects (a set of bytes with with a 1 in the nth
/ position. Ex 6 = 0010000, 3 = 00000100, etc). The arduino's unsigned int type
/ has 4 bytes (32 bits) so highest input this function can handle is 32 before
/ it overflows
void sendBlueIrisByte(unsigned int global_input_dio_bits) {
/ This is a bitwise operation that converts the input number to a binary
/ number with the 1 at the input digit.
/ Ex: 6 -> 00100000
unsigned int bitwise_dio = pow(global_input_dio_bits, 2);
Serial.write(bitwise_dio);
}
void resetBlueIrisByte() { Serial.write(0); }
bool dbPressed() { return digitalRead(DB_PIN) == 0; }