Input signal seems to be floating

Hello

I have hooked up an NPN sensor to the VMA05 shield. To test it I set the pinMode outputs then wrote minimal code for the pin I have it wired to ie pin 5
If (digitalRead(5 == HIGH)
{
digitalWrite(11, HIGH);
}

That part works fine…corresponding LED goes on (and stays on)HOWEVER when I try to turn OFF the output
delay(50);
If (digitalRead(5 == LOW)
digtalWrite(11, LOW)

The LED just blinks…do I need a pullup resistor on the input?

Hmm…may have spoken too soon when I said that the first line of code works fine.

Upon further testing I am now seeing the output LED go highvwith nothing at all connected to any of the input pins.

Any help would be appreciated.

Also tried using pinMode(5,INPUT_PULLUP);

No dice…output LED is still lighting with NOTHING attached to ANY input pin

Please have a look at the diagram on page 9 of the manual.

When digital inputs are left open, input will read ‘1’.
When pulled to GND, input will read ‘0’.

Make sure internal pull-ups are active.

Test your code by shorting digital input with a piece of wire.
This will allow you to determine if board and code works fine.

Thanks for the reply. That helped a bit. It helped to understand that when nothing is connected the pins read high.
Also shorting any if the input pins to ground does indeed light the corresponding input LED.
I’ve set the Arduino INPUTS as internal INPUT_PULLUP.

BUT…I’m still confused. And the only manual that I have found only has 4 pages…no page 9… what am I missing?

I would appreciate clarification of two things in particular.

  1. when a pin is shorted to the input ground , (green LED ON) is that pin considered LOW state?(in other words should my digitalRead look for a LOW if I want to detect a sensor that has activated)
  2. what is the input pinout correlation of the VMA05 ? Input 6=which Arduino pin?

Thanks

The kit manual has more pages than the assembled shield manual, but they are identical.

Anyway:

1)If a pin is shorted to GND, the Arduino pin will read LOW

  1. In the upper left hand corner of the diagram you see the pin correlation.

Hello and thanks for your help.

Still not seeing any logical connection between the input and output.
To simplify for testing I’ve temporarily abandoned my sensor… using the shorting wire as a substitute. I easily get Green LED’s but no impact on any of the output relays I chose (relay 10,11, 12) in any of the code combinations that I tried (I’m also relatively new to the Arduino…but hey all I’m doing here (as an example) is an… if digitalRead(5 == LOW);{digitalWrite(12, LOW) command)

As you already know the Arduino code I wrote for testing is only a couple of lines…and I have tried several combinations of that code. HELP!

Oh and I have tried to make sense of the wiring diagrams to which you directed me…but I am a novice (I apologize but my expertise with this stuff is more on the logic side than on the electronics side) I bought the VMA05 in the hope that it would help with sensor signal conditioning aspect… and save me the learning curve of having to design a circuit…which is new to me.

(I’ve also been testing an optoisolator…for the 12v inductive prox that I intended to use…but some of those specs —the CTR and mA limits— have me stymied) . Prefer to use the VMA05.

Is there a simple solution for this situation?

Also…this may sound lame…but I’m still not 100% sure about the pin correlation. Arduino pin 5 = VMA05 terminal 6…right?
One thing that has me confused is that there are 8 positions on the SK1 block but only 6 active inputs…so two are unused? If so Which two?

Also … out of curiosity…what does “SK” stand for?

Thanks

Thought this info might help
In an attempt to try and see what is happening…I wrote code to turn a relay LED (pin 12) ON (high) if the INPUT is LOW and OFF if the INPUT is HIGH.
What I got was a relay that cycles on and off very quickly (flashing the LED)

To slow this down…I added two DELAY lines. Now the LED stays ON most of the time…turning OFF briefly every 900ms.
NO INPUT CHANGES (ie shorting any of the input terminals) has any impact on the blinking

Here is the code
void loop()
{
if (digitalRead(7 == LOW))
{
delay(100);
digitalWrite(12, HIGH);
}
if (digitalRead(7 == HIGH))
{
delay(900);
digitalWrite(12, LOW);
}

bobleon,

i’ve corrected your code.

void loop()
{
   if (digitalRead(7) == LOW)
   {
      delay(100);
      digitalWrite(12, HIGH); 
   } 
   if (digitalRead(7) == HIGH)
   {
      delay(900);
      digitalWrite(12, LOW); 
   }
}

the function digitalRead reads an pin and return the status of that pin
I suggest reading the arduino reference pages for more info
https://www.arduino.cc/en/Reference/DigitalRead
Best Regards,
VEL337

THAT DID IT !!

Thanks