Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Neopixel ring and 433 MHz RF Receiver - Interrupt Problem?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Neopixel ring and 433 MHz RF Receiver - Interrupt Problem?

by gullydwarf on Mon Sep 07, 2020 7:11 pm

Hello,

I am trying to use a four button 433 MHz remote to change the colors on a 12 LED NeoPixel Ring. The board is an UNO using a small 433 MHZ receiver (RF-5V). Things work fine, the program starts, the ring is off, and I push a button on the remote. The NeoPixel Ring changes all LEDs to the desired color but then the UNO will not recognize any button pushes after that. Running the Serial Monitor shows me that no button pushes are being received after the NeoPixel Ring turns on.

I feel like this is a similar problem to the Servos and NeoPixel interrupt problem highlighted on the Adafruit website. However, I only write to the NeoPixel Ring once and then wait for another button push. It is not continually updating the NeoPixel Ring. Writing once would in theory resume the interrupts.

As a side note I had trouble using strip.fill() to change all the colors on the NeoPixel and had to resort to a for loop with strip.setPixelColor(). Trying to use strip.fill() is why red, yellow, and green are defined in the program. Any help here would also be appreciated.

Code: Select all | TOGGLE FULL SIZE
/* This sketch will control an LED with a 433 MHz remote
 *
 */

#include <RCSwitch.h>
#include <Adafruit_NeoPixel.h>

RCSwitch mySwitch = RCSwitch();

#define LED_PIN 6

#define LED_NUMPIXELS 12

Adafruit_NeoPixel strip(LED_NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

unsigned long button = 0;

uint32_t red = strip.Color(255, 0, 0);
uint32_t yellow = strip.Color(255, 255, 0);
uint32_t green = strip.Color(0, 128, 0);

void setup() {
 
  Serial.begin(9600);
  //Serial.println(red); debugging
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
  strip.setBrightness(64);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

}

void loop() {
  if (mySwitch.available()) {
    button = mySwitch.getReceivedValue();  //get code from button pressed and assign to "button"
    Serial.println(button);  //for debugging
    mySwitch.resetAvailable();
  } // end if statement
 
  if (button == 8100737) {
    for(int i=0; i<LED_NUMPIXELS; i++) {
    strip.setPixelColor(i, 255, 0, 0);
    } // end for
    strip.show();
    //button = 0;
  } // end if

  else if (button == 8100738) {
    for(int i=0; i<LED_NUMPIXELS; i++) {
    strip.setPixelColor(i, 0, 128, 0);
    } // end for
    strip.show();
    //button = 0; 
  } // end else if

  else if (button == 8100740) {
    for(int i=0; i<LED_NUMPIXELS; i++) {
    strip.setPixelColor(i, 255, 255, 0);
    } // end for
    strip.show();
    //button = 0;
  } // end else if

    button = 0; // reset button until rf received
}


Thanks for reading this. Have a good day!

gullydwarf
 
Posts: 2
Joined: Mon Aug 10, 2020 6:44 pm

Please be positive and constructive with your questions and comments.