315MHz Receiver - Interference from LED?

Hi everyone,

I've got a simple setup for testing and have run into a bit of a problem. I have an Uno and a 315 MHz reciever where I'm simply reading the input in from A5 and printing it to the serial. Results are as expected. However, I wanted to add a visual indicator in the form of an LED to blink every time a value greater than zero is received. So I added the following code:

int ledPin = 12;
unsigned long timerA;
boolean ledOn = false;

void setup() {
    Serial.begin(9600);
    pinMode(ledPin,OUTPUT);
}

void loop() {
    int sensorValue = analogRead(A5);
    Serial.println(sensorValue);
    
    if (sensorValue > 0 && !ledOn) {
      timerA = millis();
      digitalWrite(ledPin,HIGH);
      ledOn = true;
    }
    
    if (ledOn && (timerA - millis()) >= 50) {
      digitalWrite(ledPin,LOW);
      ledOn = false;
    }
}

I upload and I can see the LED blinking away, but it appears to be blinking a lot more than I think it should. So I fire up the serial console and see what's being received. With the LED plugged into my breadboard I get the following output (sample):

768
768
0
768
768
0
768
768
0
768
768
0
768
767

If I remove the LED, I get the following (sample):

0
768
0
0
0
768
768
0
0
0
0
0
768
307
768
0
365
92
0
0
0
0

The second set it what I expect to see. With the LED plugged in I get a repeating pattern for sensorValue. I'm very new to this, and I'm not sure how to best troubleshoot this issue. Is it a wiring issue? Grounding? Now quite sure how to best go about this. Any advice or recommendations would be appreciated!

sgt_b2002:
Is it a wiring issue?

That's my guess.

Grounding?

From looking at your schematic ... wait, where's your schematic?

Do you have a current limiting resistor on that LED?

Hi Coding Badly, thanks for taking the time to read my post and respond. I asked a buddy of mine to see if he had any insight and he suggested moving the ground from the LED to the Power Ground instead of the digital ground it was plugged in to. That seemed to have worked, but I'm not 100% sure why.

If you'll check the schematic...wait...yeah still no schematic! :astonished: (where's a good spot for a new person to draft arduino schematics to share online?)

In lieu of that here's a pic of the little project in question if that helps at all. Referencing the picture, moving the black wire from the digital ground to the power ground resolved the issue. I don't know why though as I thought all grounds were the same.

sgt_b2002:
where's a good spot for a new person to draft arduino schematics to share online?

If you have a scanner or digital camera, scribble something on paper and upload the image. The vast majority of the time, anything is better than nothing.

Some folks use Fritzing. Some folks use Eagle. Some folks use Microsoft Paint. I prefer AutoSketch (it's not designed for schematics so it can be tedious to use for that purpose). This looks promising... http://www.upverter.com/

So I tried Fritzing, Eagle, then Upverter. Upverter is fantastic and seems to me to be a lot easier than the first two, especially when creating a new part. Anyway, here's my schematic (finally). This was the wiring where I received that weird pattern.

To resolve the issue, I moved the ground wire from the digital ground to the analog ground (as the annotation in schematic shows). It was my understanding that the grounds on the arduino were all the same. Is this an incorrect assumption?

Thanks again!

sgt_b2002:
It was my understanding that the grounds on the arduino were all the same. Is this an incorrect assumption?

According to the schematic and my multimeter they are all connected together.

Are you still having problems?