Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Corrupt IR Codes - coding error? on: December 16, 2013, 09:22:21 am
Oh yes sorry, its a TSOP4838 - data sheet here:

I think my problem is to do with interrupts. The neopixel library temporarily disables interrupts.
As I reduce the frequency of the light updates, the ir becomes more reliable.

I could probably live with this but I probably need to think about mrburnette's approach.
2  Using Arduino / Programming Questions / Re: Corrupt IR Codes - coding error? on: December 16, 2013, 07:16:04 am
Thanks for the tips.

mrburnette, using something like the tiny85 may well be the best approach - I'd like to see what the problem is first though if possible.
AnalysIR, thanks for your suggestions. I've tried all of them except for the decoupling capacitors which I don't have here.
No joy though, even when I am sending 'all off' data to the lights, the ir signal is corrupted.

3  Using Arduino / Programming Questions / Re: Corrupt IR Codes - coding error? on: December 15, 2013, 01:56:00 pm
Hmm. Or maybe it's something to do with the neopixel library turning off interrupts.

Why would that corrupt the values though?

I'm confused.
4  Using Arduino / Programming Questions / Corrupt IR Codes - coding error? on: December 15, 2013, 11:53:53 am

I'm trying to combine Ken Schirrffs IR library with the Adafruit Neopixel library but I'm having issues.
The Ir code works fine on its own but when I integrate it with the led code (also working fine) the ir codes seem to get corrupted.
I'm not sure if this is something to do with the received code getting overwritten where it is stored in memory?

I've tried commenting out different parts of code and it works fine until I actually send data to the light string using the ColorBlip function.

Anyone shed any light on this?

#include <IRremote.h>
#include <Adafruit_NeoPixel.h>
int numpixels=51;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numpixels, 6, NEO_GRB + NEO_KHZ800);
int RECV_PIN = 2;
int code;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  strip.begin();; // Initialize all pixels to 'off'
  irrecv.enableIRIn(); // Start the receiver

void loop() {
  colorBlip(strip.Color(255, 0, 0), 25);

void testfunc() {
  for (int i=0;i<1000;i++) {

void colorBlip(uint32_t c, uint8_t wait) {
  for (int j=0; j<10;j++) {
    for(uint16_t i=0; i<strip.numPixels(); i++) {
//      switch(checkir()) {
//      case -1:
//       return;
//      case 1:
//        c=strip.Color(255,0,255);
//        break;
//      case 2:
//        c=strip.Color(0,255,0);
//        break;
//      case 3:
//        c=strip.Color(255,255,0);
//        break;
//      case 4:
//        c=strip.Color(0,0,255);
//        break;
//      }
      strip.setPixelColor(i, c);
      strip.setPixelColor(numpixels-i, c);
      strip.setPixelColor(i, 0);
      strip.setPixelColor(numpixels-i, 0);

uint8_t checkir() {
   if (irrecv.decode(&results)) {  
    long int decCode = results.value;
    switch (decCode) {
      case 49796:
      case 49836:
        code= -1;
      case 49872:
      case 49859:
      case 49688:

    irrecv.resume(); // Receive the next value
  return code;
5  Using Arduino / Programming Questions / Re: Am I wasting time with an Interrupt in this case? on: November 23, 2013, 10:08:48 am
Ok - thanks all for the advice.
6  Using Arduino / Programming Questions / Am I wasting time with an Interrupt in this case? on: November 22, 2013, 04:06:31 pm
I'm writing a little sketch where a bunch of led's are turned on or off depending on whether a sensor is touched.

The led's run a series of patterns, using loops and delays, so I thought ok I'll put the sensor on an interrupt so the Arduino gets the message no matter whats going on and can act accordingly.

I set the interrupt to change mode and change a state variable to true or false depending on whether I want the lights on or off.

Thing is then I need to put a check in each of my light patterns so that they stop if the state is off.

It occurred to me that I am effectively polling the state variable instead of polling the input pin.

Is there any advantage to this or should I just forget the interrupt?

Hopefully this should explain what I mean:
void setup() {
    attachInterrupt(0, on, CHANGE);

void loop(){

    if (state==1) {

void rainbow() {
  for (int j=0; j < 256; j++) {     // 3 cycles of all 256 colors in the wheel
    for (int i=0; i < strip.numPixels()/2+1; i++) {
      strip.setPixelColor(i, state*Wheel( (i + j) % 255));
      strip.setPixelColor(50-i, state*Wheel( (i + j) % 255));
     if (state==0) {return;};   // write all the pixels out
void change()
//set state touch or not. If not then clear matrix
7  Using Arduino / LEDs and Multiplexing / Re: Streaming Pixel Data to Arduino on: April 04, 2013, 06:43:27 pm
@tom Yes I noticed that but then I switched to the Teensy which ignores the serial rate and communicates at full USB speed.

Not sure how fast this is. 12Mb/second? Fast enough anyway.
8  Using Arduino / LEDs and Multiplexing / Re: Streaming Pixel Data to Arduino on: April 04, 2013, 06:39:59 pm
Well for me the data is coming from this processing sketch which is capturing the screen:
I changed the pixel info to match my set up and display the whole screen.

I'm trying to write a max patch that will do similar but for some reason it isn't working for me at the moment.
I can't seem to send 1536 bytes reliably from MaxMsp. That is my current problem!
Maybe I'll just stick with processing.

9  Using Arduino / LEDs and Multiplexing / Re: Streaming Pixel Data to Arduino on: April 04, 2013, 09:02:32 am
Ok I have connected my matrix to a Teensy 2.0 running the Adavision LedStream.pde sketch from here]

It works and I get around 22 fps - though that's probably got more to do with the processing screen capture patch (also part of adalight) feeding it than anything else.

Its a great start anyway. I'll keep the thread updated with any progress.
10  Using Arduino / LEDs and Multiplexing / Re: Streaming Pixel Data to Arduino on: March 31, 2013, 04:54:59 am
Yes I do also want to stream data from the Arduino to the lights but this is not the part that is giving me problems (not yet anyway!).

I actually want to stream data TO the arduino from a computer eg pipe low res video to the arduino and then on to the led array.

What I am finding difficult is a way of reliably sending this much data at the required rate and reading it quick enough without it getting scrambled, lost or stuttering.

Hope that is a bit clearer.
11  Using Arduino / LEDs and Multiplexing / Streaming Pixel Data to Arduino on: March 30, 2013, 04:51:36 pm
I've built a 512 pixel led array, using WS2801 modules and I'm wondering the best way of streaming data to it.

Each pixel receives 24 bits to drive its RGB led's so I think the whole matrix needs 1536 bytes a frame.

If I assume a frame rate of 25 fps thats 38400 bytes per second, so I'd need a serial baud rate of at least 307200, more if there are some extras involved with the serial communication.

This is probably too much for my Uno but I have a Teensy 2.0 here which I believe allows much faster communication.

Is it realistic to drive this size of array? There are solutions out there such as PixelController and Glediator but I haven't got them working with my set up yet.

Has anyone got any experience/tips/hints they'd be willing to pass on?


12  Using Arduino / Networking, Protocols, and Devices / Re: TouchOSC via Ardosc/Bonjour on: January 04, 2013, 06:31:41 am
Hey thanks for posting that code. I'll look into it.

I actually started using the z_osc library as opposed to Ardosc as I couldn't work out how to parse the incoming osc addresses using Ardosc (which I needed to do to use touch osc's multitoggle's).

I am sure this is due to inability on my part as opposed to any problems with the library. In fact I'm not even sure if there is any difference between the libraries!

I've got a basic wifi set up working now. Thanks alot for your help.

I'm wondering at what rate I can pass data to the Arduino via wifi. ie could I stream pixel data to my 20x10 array at >15fps. I never intended to do this before but now I'm wondering if its possible. Obviously it depends in part on the network. I guess OSC isn't necessarily the best way of doing this. In fact it might warrant another thread.....
13  Using Arduino / Networking, Protocols, and Devices / Re: TouchOSC via Ardosc/Bonjour on: January 02, 2013, 07:51:30 am
Hey thanks for posting this. It works. Especially once I've remembered to change the ip address in touch osc  smiley-red

I'm just back into it after the holiday break and to be honest can't remember what I am doing or why.

Now I've got your example working I'll start to build on it.

I guess I should get a teensy as memory issues are already hobbling me. I'd like to be able to store a few 'images' in memory for my 20 x 10 matrix.I did have a teensy before but snapped the usb port off it. Hate those mini usb ports!

So I guess in all honesty I haven't reached the bonjour stage yet. What I was thinking of was having ios and android devices being able to connect to the led matrix and interact collaboratively with the display. Maybe I'll do that this afternoon.

Thanks for the help. I'll report back!
14  Using Arduino / Networking, Protocols, and Devices / Re: TouchOSC via Ardosc/Bonjour on: December 16, 2012, 08:42:03 am
Thanks for replying. I bought the router from ebay here in UK - the interface is definitely in Chinese!
Its still in client mode at the moment but yes AP mode would be fine.

When I said previously I had OSC working this was via Max/MSP on my laptop. So I had Touch OSC on the Ipad talking to Max/Msp which communicated with Arduino via the serial port. It worked great so I invested in the router and now trying to do it without the laptop/Max.

I'm forgetting about the bonjour stuff for now and trying to get Ardosc communication working.
I'm just using the examples. I can send a message to my laptop from Arduino but I'm not sure I can receive one.
Its hard to tell though really! I get flashing lights on the ethernet port when I send stuff from the ipad but I can't get the 'Simple Receive' patch to work.

Tried printing messages to serial port and sending osc to my laptop but nothing yet. I did the most minor of alterations to the OSC arguments example to try and relay an ipad message back to my laptop but no luck yet!

I'll keep trying, sure I'll get there soon.

#include <SPI.h>
#include <Ethernet.h>

#include <ArdOSC.h>

byte myMac[] = { 0xEC, 0x88, 0x8F, 0xDF, 0x44, 0x44 };
byte myIp[]  = { 192, 168, 1, 50 };
byte destIp[]  = { 192, 168, 1, 106 };

int  serverPort  = 10000;

int destPort=12000;

char oscadr[]="/ard/aaa";

OSCServer server;
OSCClient client;

void setup(){
// Serial.begin(19200);
 Ethernet.begin(myMac ,myIp);
 //set callback function
void loop(){
//     Serial.println("alive! ");

void func1(OSCMessage *_mes){
  //get source ip address
  byte *sourceIp = _mes->getIpAddress();

  //get 1st argument(int32)
  int tmpI=_mes->getArgInt32(0);
  //get 2nd argument(float)
  float tmpF=_mes->getArgFloat(1);
  //get 3rd argument(string)
  int strSize=_mes->getArgStringSize(2);
  char tmpStr[strSize]; //string memory allocation

  //create new osc message
  OSCMessage newMes;
  //set destination ip address & port no
  //set argument
  //send osc message


void logIp(OSCMessage *_mes){
  byte *ip = _mes->getIpAddress();
  Serial.print(" ");

void logOscAddress(OSCMessage *_mes){

15  Using Arduino / Networking, Protocols, and Devices / TouchOSC via Ardosc/Bonjour on: December 15, 2012, 06:37:06 am
I'm wondering if anyone can help me get this working or point me towards some examples.

I have an Arduino Uno with a W5100 ethernet shield, and a TP Link WR702N connected via ethernet cable in Client Mode.

I'm hoping to send and receive OSC messages from my ipad using Touchosc to control some lighting.

I can do this already via my laptop (Ipad>Laptop>Arduino>Lights) but hoping to bypass it and go Ipad>TpLink>Arduino>Lights.

I have negotiated the Chinese admin panel and got the router into client mode. I can log into it from my browser so I think its working.

Have downloaded Ardosc and Bonjour libraries but feeling a bit overwhelmed by confusion and not sure how to test each individual step. I've searched for some guidance but haven't found any, at least not in simple enough terms.

Can anyone help?

Thanks if you can!
Pages: [1] 2