Light Strip Not Lighting

Hi All,

Please help.

I have been handed a project, that uses a light strip, but it is nothing like any of the tutorials. This project did previously work, but stoped working when our online server changed (we are using eithnet shield to get data about a page, and then we are making light strip act accordingly. The light strip looks like this link :

How it Works
Basicly : On Arduino, there are only two wires (GND & Pin 8 ) both of these wires go into a "rayexelec" chip. I am not sure of the purpose of this "rayexelec" chip. A cable then comes out of this "rayexelec" chip into the light strip.
The hardware also has a LED power supply (output 12V). One end of the power supply connects directly into the mains (plug in wall) and the other end connects into the "rayexelec" chip.

My Understanding in that the LED power supply , suppies the main power into the "rayexelec" chip for the light strip. The wires going from the arduino into the "rayexelec" chip are basicly the switch (Software written as digitalWrite(8,HIGH);. It actually seems like a simple enough circuit, but I can't get it to turn on.

I have enclosed some Pictures and Diagram :

>> http://www.rothco.ie/daragh/diaram.png

>> http://www.rothco.ie/daragh/physcialView.png

Also note, the light strips have a "cap" rather than lose wires when they are been connected.

Any help at all would be fantastic !

Notes :
The lights work perfect when connect directly to mains.
I am using a UNO board with an eithernet shield on top.
The Eithernet shelid connects correctly to twitter.

I am not sure if it is a hard ware issue or software issue :frowning: ,

The code I am using is a slightly modified version of the twitter client in the libary, which basicly turns on pin 8 :

/*
  Twitter Client with Strings
 
 This sketch connects to Twitter using an Ethernet shield. It parses the XML
 returned, and looks for <text>this is a tweet</text>
 
 You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, 
 either one will work, as long as it's got a Wiznet Ethernet module on board.
 
 This example uses the DHCP routines in the Ethernet library which is part of the 
 Arduino core from version 1.0 beta 1
 
 This example uses the String library, which is part of the Arduino core from
 version 0019.  
 
 Circuit:
  * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 21 May 2011
 by Tom Igoe
 
 This code is in the public domain.
 
 */
#include <SPI.h>
#include <Ethernet.h>


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0xBA, 0x44};
IPAddress ip(10,11,0,62); //<<< ENTER YOUR IP ADDRESS HERE!!!

// initialize the library instance:
EthernetClient client;

const int requestInterval = 60000;  // delay between requests

char serverName[] = "api.twitter.com";  // twitter URL

boolean requested;                   // whether you've made a request since connecting
long lastAttemptTime = 0;            // last time you connected to the server, in milliseconds

String currentLine = "";            // string to hold the text from server
String tweet = "";                  // string to hold the tweet
boolean readingTweet = false;       // if you're currently reading the tweet

int led=8;

void setup() {
  
  pinMode(2, OUTPUT);
  pinMode(led, OUTPUT);
  
  // reserve space for the strings:
  currentLine.reserve(256);
  tweet.reserve(150);

// initialize serial:
  Serial.begin(9600);
  // attempt a DHCP connection:
  if (!Ethernet.begin(mac)) {
    // if DHCP fails, start with a hard-coded address:
    Ethernet.begin(mac, ip);
  }
  // connect to Twitter:
  connectToServer();
}



void loop()
{

  
  if (client.connected()) {
    if (client.available()) {
      // read incoming bytes:
      char inChar = client.read();

      // add incoming byte to end of line:
      currentLine += inChar; 

      // if you get a newline, clear the line:
      if (inChar == '\n') {
        currentLine = "";
      } 
      // if the current line ends with <text>, it will
      // be followed by the tweet:
      if ( currentLine.endsWith("<text>")) {
        // tweet is beginning. Clear the tweet string:
        readingTweet = true; 
        tweet = "";
      }
      // if you're currently reading the bytes of a tweet,
      // add them to the tweet String:
      if (readingTweet) {
        if (inChar != '<') {
          tweet += inChar;
        } 
        else {
          // if you got a "<" character,
          // you've reached the end of the tweet:
          readingTweet = false;
          Serial.println(tweet);
          
          if(tweet == ">Hello Cruel World"){
           digitalWrite(2, HIGH);
           //digitalWrite(led, HIGH);
            digitalWrite(led,HIGH);
           Serial.println("LED ON!");
           
          }
          if(tweet != ">Hello Cruel World"){
           digitalWrite(2, LOW);
           Serial.println("LED OFF!");
          }
          
          // close the connection to the server:
          client.stop(); 
        }
      }
    }   
  }
  else if (millis() - lastAttemptTime > requestInterval) {
    // if you're not connected, and two minutes have passed since
    // your last connection, then attempt to connect again:
    connectToServer();
  }
}

void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println("making HTTP request...");
  // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=RandyMcTester&count=1 HTTP/1.1");
    client.println("HOST: api.twitter.com");
    client.println();
  }
  // note the time of this connect attempt:
  lastAttemptTime = millis();
}

The arduino board itself is powed by a mains plug and I am currently using a USB for testing. I have a network cable going into the eithernet board.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

The "rayexelec" box appears to be a simple relay. If the inputs or outputs got swapped accidentally that might connect the + side of the power supply to the - side of the light strips and thus cause it to not light. Has it been taken apart since it was last working?

Hi johnwasser,

The device has not been taken apart, except for the two wires (+ & -) red and black wires that connect to the LED power source, however, (assuming the original creator is in any way careful)
The brown wire (positive) coming out of the LED power source is connected to the red wire which is going into the relay box. I am assuming the red wire is positive because that's the correct color code.

Do I have to use the code to send a signal to the relay box (from pin 8 ) to activate the relay ?. Currently I am using digitalWrite(led,HIGH); , and I have defined "led" as pin 8. Should this be more digitalWrite(led,5v) as in send 5 volts or something ?.

The code works with a simple led (though directly through the Arduino e.g positive leg in pin 8, and wire going into GND. I didn't test the LED going through the relay box because of the way the circuit is made , and also I fear the 5V maybe to much for a simple LED.

Also, maybe my Light strip could be analog, but it looks like pin 8 is a digital pin ?

Can you tell me what the purpose of the relay box is ?

Cheers
Daragh

PS. Thanks for adding the to my code

This project did previously work, but stoped working when our online server changed (we are using eithnet shield to get data about a page, and then we are making light strip act accordingly.

Assuming the hardware has not been changed of part of it's failed then the more likely problem is software if it all went wrong when the server was changed. How did the server tell the arduino how and when to light the strips? Maybe the server is missing some vital script or the arduino needs some URL's or HTTP strings altering?

Thanks Riva,

It is possible. I have looked at other examples of facebook like lights, however, it appears that a couple of lines of code can be used to access a facebook social graph and return the number of likes.

So a php script on our sever would be in charge of getting the amount of likes from a facebook page, while the Arduino Eithernet sheild is consistently checking the php page to see if the number of likes is higher than the previous number. ....

basicly .php page gets number of likes. Arduino monitors .php page and determiners if a new like has been make. If a new like HAS been made, light the light strip.

I don't see why the .php would send command to light up the arduino when it is so much easier to use the eithernet sheild. Thats why I am using twitter example, its basicly the same idea.

Daragh

daragh_c:
Can you tell me what the purpose of the relay box is ?

The outputs of the Arduino are 5V and 40 mA maximum current. The relay allows the 5V signal to control the 12V circuit. Either the relay has a 5V coil that requires less then 40 mA or there is a transistor next to the relay which allows the Arduino to switch the higher current or voltage the relay needs. The pictures don't show a clear view of the relay markings or the parts on the relay board so it is hard to tell which is the case.

If you change the Blink example to use Pin 8 (your relay) can you hear the relay click on and off? If not, there is likely something wrong with the relay or the driving of the relay.

Hey All,
I managed to get the light strip working, by simply taking everything apart and putting it all back together again. The blink program makes the entire board flash so that's working as expected YAY !. Annoying that I waited until the last idea to dismantle, but sure glad it works.

I ended up using pin 8, as the eithernet sheild uses pins 10-13

Thanks a mill for everyone's help !!!

For the record the twitter code is here , But I have removed my MAC and Ip address for obvious reasons...

/*
  Twitter Client with Strings
 
 This sketch connects to Twitter using an Ethernet shield. It parses the XML
 returned, and looks for <text>this is a tweet</text>
 
 You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, 
 either one will work, as long as it's got a Wiznet Ethernet module on board.
 
 This example uses the DHCP routines in the Ethernet library which is part of the 
 Arduino core from version 1.0 beta 1
 
 This example uses the String library, which is part of the Arduino core from
 version 0019.  
 
 Circuit:
  * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 21 May 2011
 by Tom Igoe
 
 This code is in the public domain.
 
 */
 
int led=8;
 
#include <SPI.h>
#include <Ethernet.h>


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX};
IPAddress ip(XX,XX,XX,XXX); //<<< ENTER YOUR IP ADDRESS HERE!!!

// initialize the library instance:
EthernetClient client;

const int requestInterval = 10000;  // delay between requests

char serverName[] = "api.twitter.com";  // twitter URL

boolean requested;                   // whether you've made a request since connecting
long lastAttemptTime = 0;            // last time you connected to the server, in milliseconds

String currentLine = "";            // string to hold the text from server
String tweet = "";                  // string to hold the tweet
boolean readingTweet = false;       // if you're currently reading the tweet



void setup() {
  
  pinMode(led, OUTPUT);
  
   //reserve space for the strings:
 currentLine.reserve(256);  
 tweet.reserve(150);

//initialize serial:
 Serial.begin(9600);
 //attempt a DHCP connection:
  if (!Ethernet.begin(mac)) {
    // if DHCP fails, start with a hard-coded address:
    Ethernet.begin(mac, ip);
  }
  // connect to Twitter:
 
  connectToServer();
}



void loop()
{

  
    
  if (client.connected()) {
    if (client.available()) {
      // read incoming bytes:
      char inChar = client.read();

      // add incoming byte to end of line:
      currentLine += inChar; 

      // if you get a newline, clear the line:
      if (inChar == '\n') {
        currentLine = "";
      } 
      // if the current line ends with <text>, it will
     // be followed by the tweet:
      if ( currentLine.endsWith("<text>")) {
        // tweet is beginning. Clear the tweet string:
        readingTweet = true; 
        tweet = "";
      }
      // if you're currently reading the bytes of a tweet,
      // add them to the tweet String:
      if (readingTweet) {
        if (inChar != '<') {
          tweet += inChar;
        } 
        else {
          // if you got a "<" character,
          // you've reached the end of the tweet:
          readingTweet = false;
          Serial.println(tweet);
          
          if(tweet == ">Hello Cruel World"){
           Serial.println("LED ON!");
           flashLight();
           delay(3000);
           
          }
          if(tweet != ">Hello Cruel World"){
          digitalWrite(led, LOW);
           Serial.println("LED OFF!");
          }
          
          // close the connection to the server:
          client.stop(); 
          Serial.println("Closed Connection");
        }
     }
    }   
  }
  else if (millis() - lastAttemptTime > requestInterval) {
    // if you're not connected, and two minutes have passed since
    // your last connection, then attempt to connect again:
    connectToServer();
  }
}


void flashLight(){
  
  Serial.println("Turning on Light");
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(5000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);  
  
}

void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println("making HTTP request...");
  // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=RandyMcTester&count=1 HTTP/1.1");
    client.println("HOST: api.twitter.com");
    client.println();
    digitalWrite(led, HIGH);
  }
  // note the time of this connect attempt:
  lastAttemptTime = millis();
}

Glad you got it working.