I've made a simple little setup with an Arduino Nano, 433 MHz receiver, TIP120 transistor and a 12V LED strip.
Simple bit of code, when the arduino receives certain codes over 433 it changes the brightness of the LED strip.
My issue is that once the PWM value is set it fails to receive anymore 433 signals unless I remove the common ground wire from the transistor.
There's some exceptions - when I use analogWrite and set the value to 0 or 255 it still receives 433 signals. Using SoftPWM it only receives when it is set to 0.
Photo of the circuit attached.
Anyone have any ideas why this is happening? And how to fix it?
Current sketch using SoftPWM
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
#include <SoftPWM.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(1); // Receiver on inerrupt 0 that is pin #2
SoftPWMBegin();
SoftPWMSet(10, 0);
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
}
else if (mySwitch.getReceivedValue() == 1601455){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 100);
}
else if (mySwitch.getReceivedValue() == 1601447){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 0);
}
else if (mySwitch.getReceivedValue() == 1601454){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 20);
}
else if (mySwitch.getReceivedValue() == 1601446){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 40);
}
else if (mySwitch.getReceivedValue() == 1601446){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 60);
}
else if (mySwitch.getReceivedValue() == 1601445){
Serial.print("Received ");
Serial.println( mySwitch.getReceivedValue() );
SoftPWMSetPercent(10, 80);
}
else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
}
mySwitch.resetAvailable();
}
}