Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Beginner: How To Wire Digital Pins w/ Installed Shield? on: November 08, 2013, 01:54:07 pm
This is going to be very basic, and I have to apologize up front for even asking it.  I'm not 100% this is the place to post this; however, I am hoping someone can help me out.

I have the Arduino Uno board and just picked up the Seeed Relay Shield.  I quickly want to put together a project that will control a lamp with a motion sensor.  I have the shield controlling a lamp successfully through programming; however, how the hell do I add in a motion sensor?

I know the shield is not using up all the ports; however, they are all plugged in eliminating the possibility of using the 5V, GND, and D3 port on the Arduino.  I know I could solder wires, but I just want to test the thing out.  Is there anyway to breadboard this sucker in there?  What ports are used at minimum between a Seeed relay shield and an Arduino?  I tried breadboarding my Arduino pin 7 to the shields D1 port, but I had no luck.
2  Using Arduino / LEDs and Multiplexing / Re: [OPEN] Radio Shack - Single Pin LED Strip - Help on: April 21, 2013, 06:26:38 pm

You waited a whole seven hours before bumping? That's less time than some people were in bed.

Start here: https://www.sparkfun.com/tutorials/317


Thanks for the information... it must be defined in the include file pgmspace.h file, because it's not defined in the code anywhere that I can see.  I thought maybe it was a default Arduino data type.  I will look into the pgmspace.h more and check out to see what that data type even is.  I would like to read what that data type is outputting, but I can't even get it to print out on the serial monitor. Ideally I would just like to just eliminate the PROGMEM and just have a value sent directly to the strip, from there I could figure out the rest of the program.

Also, it should have been 2 days since the original post; I wouldn't bump in seven hours.
3  Using Arduino / LEDs and Multiplexing / Re: Temperature Displayed on 4 Digit 7 segment (common anode) on: April 20, 2013, 04:52:55 pm
Very nice project!  My original inspiration in buying an Arduino was to create a thermostat for temperature in a house.  Output current temperature, allow input through maybe an Android cell phone to adjust temperature and automatic shut off when that temperature is reached.  Something very similar to the NEST thermostat system seen here:

http://www.nest.com/

Except not as pretty.
4  Using Arduino / LEDs and Multiplexing / Re: [OPEN] Radio Shack - Single Pin LED Strip - Help on: April 20, 2013, 04:48:37 pm
I'm sure this community does not allow bump posts; however, I am checking this post multiple times a day looking for some help or advice on how to proceed.  I can contribute to the above code by stating that I am using an Arduino Uno.  Another question I came up with is the uint32_t data type.  I can find a lot of people using it online; however, I don't see much documentation as to what it is or how it works in storing data.  Any help there would also be greatly appreciated in reference to the above code.
5  Using Arduino / LEDs and Multiplexing / Re: Radio Shack - Single Pin LED Strip Help on: April 18, 2013, 09:43:07 pm
For anyone who wants the original code that Radio Shack supplies to their Level 1 Beginners, I had to post in a new message because of the message limit... This is what I had to work with originally.

Code:
#include <avr/pgmspace.h>

// ******** DEBUG ==== should auto config to adapt different mother board *********
#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO
#define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO
#define STRIP_PINOUT (DDRC=0xFF)    // for UNO

PROGMEM const unsigned long pattern_test_red[10][10]={
  {0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000,0x000000},
  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xff0000},
};

//HAD TO ELIMINATE ABOUT 6 MORE PATTERNS BECAUSE OF MESSAGE LIMIT

PROGMEM const unsigned long pattern_all_on[10][10]={
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
  {0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff},
};

// *                            Power Up Init.

void setup() {               

  STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use

  reset_strip();
  //noInterrupts();

}

// *                            Main Loop

void loop()
{
int seconds=0;
//send_1M_pattern(pattern_all_on,10,100);
   
 
  while (1)
  {
    send_digits_pattern(pattern_20digs_mix,seconds );
seconds++;
if(seconds>19)seconds=0;
  }
}

// Function Name  : send_1M_pattern
// Description    : Transmit pattern to whole 1 meter strip                 
// Input          : pointer to ROM pattern; pattern length; frame rate

void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate)
{
  int i=0;
  int j=0;
  uint32_t temp_data;

  for (i=0;i<pattern_no;i++)
  {
    noInterrupts();
    for (j=0;j<10;j++)
    {
      temp_data=pgm_read_dword_near(&data[i][j]);
      send_strip(temp_data);
    }
    interrupts();

    delay(frame_rate);

  }
}

void send_digits_pattern(const unsigned long data[][9], int coutner)
{
  int i=coutner;
  int j=0;
  uint32_t temp_data;

    noInterrupts();
    for (j=0;j<9;j++)
    {
      temp_data=pgm_read_dword_near(&data[i][j]);
      send_strip(temp_data);
    }
    interrupts();

    delay(1000); //1s
}


// Function Name  : send_strip
// Description    : Transmit 24 pulse to LED strip               
// Input          : 24-bit data for the strip

void send_strip(uint32_t data)
{
  int i;
  unsigned long j=0x800000;
 
 
  for (i=0;i<24;i++)
  {
    if (data & j)
    {
      DATA_1;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");   
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      DATA_0;
    }
    else
    {
      DATA_1;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");   
      DATA_0;
    }

    j>>=1;
  }


 
}


// Function Name  : reset_strip
// Description    : Send reset pulse to reset all color of the strip

void reset_strip()
{
  DATA_0;
  delayMicroseconds(20);
}
6  Using Arduino / LEDs and Multiplexing / [OPEN] Radio Shack - Single Pin LED Strip - Help on: April 18, 2013, 09:26:09 pm
EDIT: Here is the strip that I own: http://www.radioshack.com/product/index.jsp?productId=16306856 Hope that helps.

Hello everyone, new to the forums, new to the Arduino, new to this nightmare of an LED strip.  I already know I made a mistake by purchasing the Radio Shack strip, and I should have purchased one off adafruit.com; however, I'm getting close I feel to figuring this thing out... I just need a little help in the right direction.

After extensively searching Google/YouTube, it seems just about nobody has any useful example code on this strip.  The documentation Radio Shack gives you (As a 'Level 1 Beginner') is more useful as toilet paper than it is a tutorial on how to use the strip.  I would give the code, but it's way too long.

After looking through it and getting rid of all the garbage they supply, I was able to shrink it down to this... and I was able to grasp a little understanding of how their code works.  What I can't understand is that send_strip function or why the data is stored in the flash memory rather than just sent straight out... anyway... here is the code that I have it down to:

Code:
#include <avr/pgmspace.h>

// ******** DEBUG ==== should auto config to adapt different mother board *********
#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO
#define DATA_0 (PORTC &=  0XFE)    // DATA 0    // for UNO
#define STRIP_PINOUT (DDRC=0xFF)    // for UNO

//Actually is GBR not RGB format

PROGMEM unsigned long outputvalue[][10]={
  {0X009900, 0X0089AA, 0X007700, 0XFF6600, 0X005500, 0XDD4400, 0X003300, 0X002200, 0X001100, 0X000000},
  };

void setup()
{  
  STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use

  reset_strip();
  //noInterrupts();
}

void loop()
{
  send_1M_pattern(outputvalue);
  delay(50);
}

void send_1M_pattern(unsigned long data[][10])
{
  int i=0;
  int j=0;
  int frame_rate = 10;
  uint32_t temp_data;
  
  noInterrupts();
  
  for (j=0;j<10;j++)
  {
    temp_data=pgm_read_dword_near(&data[i][j]);
    send_strip(temp_data);
  }
  interrupts();

  delay(frame_rate);
}

void send_strip(uint32_t data)
{
  int i;
  unsigned long j=0x800000;
  
  for (i=0;i<24;i++)
  {
    if (data & j)
    {
      DATA_1;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");    
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      DATA_0;
    }
    else
    {
      DATA_1;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");    
      DATA_0;
    }

    j>>=1;
  }
}

void reset_strip()
{
  DATA_0;
  delayMicroseconds(20);
}

Much cleaner.  Here's the problem.  How can I change the output color on the fly?  Since the data is stored in the flash memory before the program even starts, I am unsure how to change it.  I would rather eliminate the memory aspect of the code all together and just have it pass an array if that would work.  I don't understand the defines up top, I don't understand why it has to be stored (or how to change it), and I don't understand that send_strip function at all.

Can somebody PLEASE save me (and I'm sure MANY others) from bashing my head against a wall.
Pages: [1]