Skip to content

Instantly share code, notes, and snippets.

@takano32
Created May 31, 2014 14:15
Show Gist options
  • Save takano32/18fc571f823d5236b09f to your computer and use it in GitHub Desktop.
Save takano32/18fc571f823d5236b09f to your computer and use it in GitHub Desktop.
#include <RCS620S.h>
#include <inttypes.h>
#include <string.h>
#define COMMAND_TIMEOUT 400
#define PUSH_TIMEOUT 2100
#define POLLING_INTERVAL 500
#define LED_PIN 13
RCS620S rcs620s;
void setup() {
int ret;
// Serial.println("Setup...");
pinMode(LED_PIN, OUTPUT); // for Polling Status
digitalWrite(LED_PIN, LOW);
Serial.begin(115200); // for RC-S620/S
// initialize RC-S620/S
ret = rcs620s.initDevice();
while (!ret) {} // blocking
}
void loop() {
int ret, i;
// Polling
digitalWrite(LED_PIN, HIGH);
rcs620s.timeout = COMMAND_TIMEOUT;
ret = rcs620s.polling();
if(ret) {
delay(3000);
// Serial.print("IDm:");
for (i = 0; i < 8; i++) {
// if(rcs620s.idm[i] / 0x10 == 0) Serial.print(0);
// Serial.print(rcs620s.idm[i], HEX);
}
} else {
// println("Polling...");
}
rcs620s.rfOff();
digitalWrite(LED_PIN, LOW);
delay(POLLING_INTERVAL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment