Created
August 20, 2012 17:09
-
-
Save masarugen/3405890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
#include <RCS620S.h> | |
#define COMMAND_TIMEOUT 400 | |
#define POLLING_INTERVAL 500 | |
#define LED_PIN 13 | |
LiquidCrystal lcd = LiquidCrystal(5, 6, 7, 8, 9, 10, 11); | |
RCS620S rcs620s; | |
void setup() { | |
int ret; | |
pinMode(LED_PIN, OUTPUT); // for Polling Status | |
digitalWrite(LED_PIN, LOW); | |
Serial.begin(115200); // for RC-S620/S | |
lcd.begin(16, 2); // for LCD | |
// 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(); | |
lcd.clear(); | |
if(ret) { | |
lcd.print("IDm:"); | |
lcd.setCursor(0, 1); | |
for(i = 0; i < 8; i++) | |
{ | |
if(rcs620s.idm[i] / 0x10 == 0) lcd.print(0); | |
lcd.print(rcs620s.idm[i], HEX); | |
} | |
} else { | |
lcd.print("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