Go Down

Topic: Getting Dim LEDs on LOW digitalWrite (Read 454 times) previous topic - next topic

Kubba

Jun 18, 2019, 08:24 pm Last Edit: Jun 18, 2019, 08:34 pm by Kubba Reason: can't upload attachment in any form. 413 error or something.
Hiya,

I'm working on a simple state change circuit. The idea is that an Arduino Nano monitors the outputs of a board to an array of sensors and devices. If the board sends a signal to its sensors, the Arduino detects it and sends a pin with a resistor and LED high. My schematic won't upload, but here is a copy of the code:

Code: [Select]

  void setup() {
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  
  //Pin 3 Input controls Pin 11 Output. Pin 4 Input controls Pin 12 Output.

}

void loop() {

if (digitalRead(3) == HIGH) {
  
    digitalWrite(11, HIGH);
 
  } else {

    digitalWrite(11, LOW);  
}


if (digitalRead(4) == HIGH) {
  
    digitalWrite(12, HIGH);
 
  } else {

    digitalWrite(12, LOW);  
  }
}


My issue is that while Pin 11 functions as it should (that is, the Arduino LED flashes on and off as the other board's sensor is triggered), Pin 12 has a constant output regardless of whether or not there is a state change. I've swapped the LEDs with similar results. I've also noted that some of the unused pins on the Arduino make attached LEDs glow.

Aside from my Nano being fried somehow (which could be the case), is there any other reason why I might be experiencing these issues?

Thanks

Grumpy_Mike

#1
Jun 18, 2019, 10:01 pm Last Edit: Jun 18, 2019, 10:03 pm by Grumpy_Mike
Quote
My schematic won't upload,
This is a pity because your problem is almost certainly with your hardware.

Read again:-
How to use this forum
And
Image guide
image guide


Quote
is there any other reason why I might be experiencing these issues?
Yes lots, mainly to do with a common ground not being connected, or the way these inputs are wired or the way you have translated your schematic to your physical setup.

Quote
Aside from my Nano being fried somehow
Then try swapping over the input pins or try other input pins.

Kubba

Thanks for the reply!

Well, hopefully the schematic looks okay as an attachment.

Quote
Yes lots, mainly to do with a common ground not being connected, or the way these inputs are wired or the way you have translated your schematic to your physical setup.
I had to solder a lot of things between my power supply and this project, but I am 95% sure that my schematic resembles my actual circuit.

Quote
Then try swapping over the input pins or try other input pins.
I'll be sure to try that in a bit once I get home.

PaulRB

Well, hopefully the schematic looks okay as an attachment.
You were just asked to read the image guide.

If you are going to ignore advice already given, why should we give you any more advice?

Paul__B

OK, I looked!  :smiley-eek:

Do not use "Vin" on an Arduino.

What on earth is an "F board"?  Sounds rude!  :smiley-roll:

Kubba

Quote
OK, I looked!  :smiley-eek:
Ay thanks.

Quote
Do not use "Vin" on an Arduino.
I think I can use Vin if I am using a regulated power source, yeah? My power supply is set to 5 volts.

Quote
What on earth is an "F board"?  Sounds rude!  :smiley-roll:
F Board is a Furby's main board. I'm working on a rather ridiculous modification to it.


I got a second Nano to duplicate the issue I'm having using the same code and hardware configuration.

Grumpy_Mike

Quote
I think I can use Vin if I am using a regulated power source, yeah? My power supply is set to 5 volts.
No.
If you are going to use Vin then your power supply has to be set between 7 and 9V inorder to supply 5V out of the regulator.

You have
Quote
Pin 12 has a constant output regardless of whether or not there is a state change.
Which means that the pin 4 input is not being driven correctly. The schematic shows pin 4 being connected to an IR diode that connects direct to ground. So Pin 4 will never see a voltage greater than about 1.6V, because that is the forward voltage of an IR LED. So Pin 4 will always read as a LOW.

Does the mysterious F-board contain a current limiting resistor? If not then not only will this input not work but you could be damaging something on the board.

Simple fix, remove the IR LED, and replace it with a 220R resistor in series with the IR LED, having Pin 4 still connected to the same pin on the F-board.

Note that you show the ground connected to the F-board but you have not shown the negative output of the thing driving both Arduino pins connected to ground. Are these at the same potential as the ground?

Kubba

#7
Jun 19, 2019, 10:25 pm Last Edit: Jun 19, 2019, 10:27 pm by Kubba
Thanks again for the reply.

Quote
If you are going to use Vin then your power supply has to be set between 7 and 9V inorder to supply 5V out of the regulator.
Turns out I was using 5V. I just let myself get confused.

Quote
Which means that the pin 4 input is not being driven correctly. The schematic shows pin 4 being connected to an IR diode that connects direct to ground. So Pin 4 will never see a voltage greater than about 1.6V, because that is the forward voltage of an IR LED. So Pin 4 will always read as a LOW.
Oh. I assumed any voltage above 0 would trigger a state change on any input pin. In review, it seems kinda pointless to try and detect state changes in that diode anyhow; this particular diode is always on and wouldn't look particularly good on my blinkenlights display. However, there is a detector diode that goes high every time it senses an IR pulse. If I wanted to detect a state change in that one, how might I do it?

Quote
Does the mysterious F-board contain a current limiting resistor? If not then not only will this input not work but you could be damaging something on the board.
Thanks for asking, and there are current-limiting resistors on the board. If I did fry an F Board (and I have), I have others ready to go. To be specific, the F Board is a 1998 Furby's main board. I'm attempting to read state changes of differing components on the Furby and have it reflected in an array of LEDs.

Quote
Note that you show the ground connected to the F-board but you have not shown the negative output of the thing driving both Arduino pins connected to ground. Are these at the same potential as the ground?
I should have specified. Everything that is shown as ground on my schematic is really going to -V. These should have the same potential as ground, but sometimes I forget my fundamentals.

So I've messed around some more. The two components I am trying to read state changes for are a simple cam switch and the motor. The code has changed slightly as well.

Code: [Select]


void setup() {
  pinMode(13, INPUT);
  pinMode(12, INPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
 
  //Pin 13 Input controls Pin 3 Output. Pin 12 Input controls Pin 2 Output.

}

void loop() {

if (digitalRead(13) == HIGH) {
 
    digitalWrite(3, HIGH);

  } else {

    digitalWrite(3, LOW);
}


if (digitalRead(12) == HIGH) {
 
    digitalWrite(2, HIGH);

  } else {

    digitalWrite(2, LOW);
  }
}


The schematic of my first configuration and results can be seen here:



So I'm essentially having the same issue as before. L1 toggles on and off with the motor while L2 does not toggle when the cam switch is closed.

I added a second Nano with the above code to see what would happen:



Here, both LEDs function as they should. I tried hooking up D12 and D2 to the second Nano, and even then, D2 is always high. The strange thing is that on both Nanos, Pin 2 is high regardless of input from D12. I'll triple check for shorts and look for mistakes in translating my schematic, but it would be the third time I've done so. Any thoughts?

Grumpy_Mike

#8
Jun 19, 2019, 11:24 pm Last Edit: Jun 19, 2019, 11:26 pm by Grumpy_Mike
Quote
So I'm essentially having the same issue as before.
Because you have still not got the wiring of pin 12 correct.

It needs a pull up resistor assuming the other unlabelled wire on the cam is going to ground.

You should never leave an input not connected to something, this is known as the pin floating and results in the pin reading a random high or low. The best way is to wire the switch between the input and ground and have a pull up resistor from the input to 5V. You can use the built in PULLUP resistors by specifying it in the pinMode call :- INPUT_PULLUP

There is no need to use two Arduinos, that is pure folly.

Kubba

Quote
You should never leave an input not connected to something, this is known as the pin floating and results in the pin reading a random high or low. The best way is to wire the switch between the input and ground and have a pull up resistor from the input to 5V. You can use the built in PULLUP resistors by specifying it in the pinMode call :- INPUT_PULLUP
Oh okay. I'm getting inconsistent results but have reached a satisfactory state. I'll have to play around with it during the weekend.

Quote
There is no need to use two Arduinos, that is pure folly.
It is already part of the design. I don't intend on using it for state change detection in the end, though.

A picture:



Thanks for your patience. I'll probably post again.

Go Up