Advertisement
Guest User

Untitled

a guest
Mar 19th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. //#include <stdlib.h>
  3. #define DELA 1200  // Time between message sends.
  4. SoftwareSerial RFID(2, 3); // RX and TX
  5. const int ledPin = 13;
  6. int i;
  7.  
  8. void setup()
  9. {
  10.   RFID.begin(9600);    // start serial to RFID reader
  11.   Serial.begin(9600);  // start serial to PC
  12.      pinMode(ledPin, OUTPUT); // Initialize pin as output.
  13. }
  14.  
  15. void loop()
  16. {
  17.   if (RFID.available() > 0)
  18.   {
  19.      i = RFID.read();
  20.      Serial.print(i, DEC);
  21.      Serial.print(" ");
  22.         if ( Serial.available() )
  23.    { light(Serial.read() - '0'); } // How many positions past ASCII 0?
  24.    delay (DELA);
  25.   }
  26. }
  27.  
  28. void light(int n) {
  29.   for (int i = 0; i < n; i++)
  30.   {
  31.   digitalWrite(ledPin, HIGH);   // Turn the LED on.
  32.   delay(DSHORT);      
  33.   digitalWrite(ledPin, LOW);   // Turn the LED off.
  34.   delay(DSHORT);               // Wait.
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement