Twitter Poem Box (Twitting Lamp)

details

This project is about the poem twitting lamp. The lamp incorporates an RFID reader and the BlinkM(a programable RGB LED). The lamp tweets random colored poems when it detects one of the three RFID cards which each represent one of the primary colors of light. These colors can be mixed allowing you to make seven different colors of poems. Below is the tweeting message sent by the lamp.

tweet lamp-1

 

The author made two versions of the lamp – one is using  Seeed Studio’s RFID Reader and the other is using Parallax’s RFID Reader system. In both of them, Arduino Ethernet shield is used for Internet connectivity and transmitting the tweet message.

As you see below movie, the lamp sends the different tweeting according to the RFID card type.

 

Code

#include <Wire.h>
#include "BlinkM_funcs.h"

volatile long reader1 = 0;
volatile int reader1Count = 0;

#define blue [your id tag # here]
#define red [your id tag # here]
#define green [your id tag # here]

long prevTime;
int card1;
int card2;
int count=0;

long dec;
int color;

byte r,g,b;

byte addr = 0x09;


void reader1One(void) {
     reader1Count++;
     reader1 = reader1 << 1;
     reader1 |= 1;
}


void reader1Zero(void) {
     reader1Count++;
     reader1 = reader1 << 1;
}


void setup(){
     BlinkM_beginWithPower();
     Serial.begin(9600);
    
    // Attach pin change interrupt service routines from the Wiegand RFID readers
    attachInterrupt(0, reader1Zero, RISING);//DATA0 to pin 2
    attachInterrupt(1, reader1One, RISING); //DATA1 to pin 3
     delay(10);

     // the interrupt in the Atmel processor misses out the first negitave pulse as the inputs are already high,
     // so this gives a pulse to the reader input line to get the interrupts working properly.
     // Then clear out the reader variables.
     // The readers are open collector sitting normally at a one so this is OK
    for(int i = 2; i<4; i++){
        pinMode(i, OUTPUT);

        // enable internal pull up causing a one
        digitalWrite(i, HIGH); 

       // disable internal pull up causing zero and thus an interrupt
       digitalWrite(i, LOW);
      
       pinMode(i, INPUT);
       digitalWrite(i, HIGH); // enable internal pull up
     }

    delay(10);

     // put the reader input variables to zero
     reader1 = 0;
     reader1Count = 0;
}


void loop() {
     readCard();
}

void readCard(){
     if(count<2){
          if(reader1Count >=26){
               int serialNumber=(reader1 >> 1) & 0x3fff;
               int siteCode= (reader1 >> 17) & 0x3ff;
               dec = (reader1& 0xfffffff);
               if(count==0){
                    r=0;
                    b=0;
                   g=0;
                }
               Serial.print("dec=");
               Serial.println(dec);


                switch(dec){
                case red:
                      r=255;
                      break;
          
                case green:
                       g=255;
                      break;
 
                case blue:
                       b=255;
                       break;
    
                default:
               color=0;

               Serial.print("new tag");
               Serial.print(reader1& 0xfffffff);
           }

           displayColor();
           reader1 = 0;
           reader1Count = 0;
      }else if(reader1Count == 0){
           displayColor();
      }

     if(millis()-prevTime>2000){
          count++;
          prevTime=millis();
       }
    }else{
      count=0;
    }
 }

void displayColor(){
     BlinkM_fadeToRGB(addr,r,g,b);
}

 

 

If you go to Instructables, you can see all process how this project has been developed and get all source code.

 

This project is about the poem twitting lamp. The lamp incorporates an RFID reader and the BlinkM(a programable RGB LED). The lamp tweets random colored poems when it detects one of the three RFID cards which each represent one of the primary colors of light. These colors can be mixed allowing you to make seven different colors of poems. Below is the tweeting message sent by the lamp.

tweet lamp-1

 

The author made two versions of the lamp – one is using  Seeed Studio’s RFID Reader and the other is using Parallax’s RFID Reader system. In both of them, Arduino Ethernet shield is used for Internet connectivity and transmitting the tweet message.

As you see below movie, the lamp sends the different tweeting according to the RFID card type.

 

Code

#include <Wire.h>
#include "BlinkM_funcs.h"

volatile long reader1 = 0;
volatile int reader1Count = 0;

#define blue [your id tag # here]
#define red [your id tag # here]
#define green [your id tag # here]

long prevTime;
int card1;
int card2;
int count=0;

long dec;
int color;

byte r,g,b;

byte addr = 0x09;


void reader1One(void) {
     reader1Count++;
     reader1 = reader1 << 1;
     reader1 |= 1;
}


void reader1Zero(void) {
     reader1Count++;
     reader1 = reader1 << 1;
}


void setup(){
     BlinkM_beginWithPower();
     Serial.begin(9600);
    
    // Attach pin change interrupt service routines from the Wiegand RFID readers
    attachInterrupt(0, reader1Zero, RISING);//DATA0 to pin 2
    attachInterrupt(1, reader1One, RISING); //DATA1 to pin 3
     delay(10);

     // the interrupt in the Atmel processor misses out the first negitave pulse as the inputs are already high,
     // so this gives a pulse to the reader input line to get the interrupts working properly.
     // Then clear out the reader variables.
     // The readers are open collector sitting normally at a one so this is OK
    for(int i = 2; i<4; i++){
        pinMode(i, OUTPUT);

        // enable internal pull up causing a one
        digitalWrite(i, HIGH); 

       // disable internal pull up causing zero and thus an interrupt
       digitalWrite(i, LOW);
      
       pinMode(i, INPUT);
       digitalWrite(i, HIGH); // enable internal pull up
     }

    delay(10);

     // put the reader input variables to zero
     reader1 = 0;
     reader1Count = 0;
}


void loop() {
     readCard();
}

void readCard(){
     if(count<2){
          if(reader1Count >=26){
               int serialNumber=(reader1 >> 1) & 0x3fff;
               int siteCode= (reader1 >> 17) & 0x3ff;
               dec = (reader1& 0xfffffff);
               if(count==0){
                    r=0;
                    b=0;
                   g=0;
                }
               Serial.print("dec=");
               Serial.println(dec);


                switch(dec){
                case red:
                      r=255;
                      break;
          
                case green:
                       g=255;
                      break;
 
                case blue:
                       b=255;
                       break;
    
                default:
               color=0;

               Serial.print("new tag");
               Serial.print(reader1& 0xfffffff);
           }

           displayColor();
           reader1 = 0;
           reader1Count = 0;
      }else if(reader1Count == 0){
           displayColor();
      }

     if(millis()-prevTime>2000){
          count++;
          prevTime=millis();
       }
    }else{
      count=0;
    }
 }

void displayColor(){
     BlinkM_fadeToRGB(addr,r,g,b);
}

 

 

If you go to Instructables, you can see all process how this project has been developed and get all source code.

 

COMMENTS

Please Login to comment
  Subscribe  
Notify of