I'm working on a project where I'm basically making a keyboard for iOS devices. I'm using a bluetooth module (blueSmirf HID from sparkfun) and an Arduino Uno. I'm using the SoftwareSerial library.
I'm trying to clean up a bit of my code so I created this following helper function:
void sendKey(const byte scanCode[], int dly) {
//scanCode is a array of 11 hex codes
//dly is the amount of delay between the press and the release
mySerial.write(scanCode, sizeof(scanCode));
delay(dly);
mySerial.write(RELEASE, sizeof(RELEASE));
}
But when I put this into my loop(), my Arduino Uno doesn't seem to do anything... Is there any way to encapsulate the press, delay, and release into a helper function? It works when it's not in a helper function.
This doesn't work:
else if (vf < 512) { //navigate left
/* mySerial.write(LEFT, sizeof(LEFT));
delay(100);
mySerial.write(RELEASE, sizeof(RELEASE)); */
sendKey(LEFT, 100);
}
This works:
else if (vf < 512) { //navigate left
mySerial.write(LEFT, sizeof(LEFT));
delay(100);
mySerial.write(RELEASE, sizeof(RELEASE));
}
What am I doing wrong?