how to check if there is "1" on output pin in arduino and display it?

i need a simple program that runs in the loop section and keep checking in the ports if there is a "1" and if there is to display: Port "XXXX" is OK.

Well, one argument goes that if it's on an output, you must've written it, so you should know what's on it. Or, you could just read it.

Groove: Well, one argument goes that if it's on an output, you must've written it, so you should know what's on it. Or, you could just read it.

the arduino is one part of an entire system of mine, i need to use it to check if there is a connection between point a and point b, or in other words if there is a connection between digital 40 and digital 38 (for example)

could you please be more specific? i need to know how to code this, i'm only a beginner in this whole programing thing....

and i use Arduino due

i need to use it to check if there is a connection between point a and point b, or in other words if there is a connection between digital 40 and digital 38 (for example)

You just moved the goalposts considerably.

In your example will pins 38 and 40 be connected by a switch ? Could pin 38 or 40 be connected to several other pins in your circuit and that would need to be detected ?

Can you please explain more about what you are doing as there may be other ways to achieve it.

UKHeliBob:
You just moved the goalposts considerably.

In your example will pins 38 and 40 be connected by a switch ?
Could pin 38 or 40 be connected to several other pins in your circuit and that would need to be detected ?

Can you please explain more about what you are doing as there may be other ways to achieve it.

all the lines are connected to another relay board that swith on/off the lines, there is only one path for each pair of arduino ports, i simply need to identify that i recive “1” and to print it into the command line, i need to use this system as a “self test” for another system.

the relay board has a built in program that enable me to select which relay to close, and i need so check with the arduino that i do recive “1” when expected.

Here is something to get you started, but it is very basic stuff.

const byte inPin = 10;

void setup()
{
  Serial.begin(115200);
  pinMode(inPin, INPUT_PULLUP);
}

void loop()
{
  if (digitalRead(inPin) == HIGH)
  {
    Serial.println("HIGH");
  }
}

Extend the code to multiple pins by using a for loop and an array of pin numbers

KobiAflalo: the arduino is one part of an entire system of mine, i need to use it to check if there is a connection between point a and point b, or in other words if there is a connection between digital 40 and digital 38 (for example)

Do you mean electrical connection? You want to wiggle the value on one pin and check to see if another pin follows it (and is presumably connected)?

UKHeliBob: Here is something to get you started, but it is very basic stuff.

const byte inPin = 10;

void setup() {   Serial.begin(115200);   pinMode(inPin, INPUT_PULLUP); }

void loop() {   if (digitalRead(inPin) == HIGH)   {     Serial.println("HIGH");   } }



Extend the code to multiple pins by using a for loop and an array of pin numbers

if i understand you correctly you want me to use the serial port, but i use the ports that are on the board and not on the usb, all the wires go out from the arduino to the rest of the circuit, i tried to write something and came up with this, but i don't know how to continue:

//initial variables //pin numbers const int ARD1P811=11; const int ARD1P812=12; //status notifications string statusok="port is ok" string statusfault="port is bad"

void setup(){ //initialize the port i/o pin mode(ARD1P811,INPUT); pin mode(ARD1P812,OUTPUT);

void loop(){ //run the program and check the ports pin1status=digitalread(ARD1P811); if(pin1status==HIGH); //display ok

.... .... ... ...

and now i don't know how to continue, please help

if(pin1status==HIGH);

I can see that that cannot do what you expect. Have you ever seen any other "if" s that look like that?

Groove: if(pin1status==HIGH);

I can see that that cannot do what you expect. Have you ever seen any other "if" s that look like that?

i saw this in one of the examples, please help me

i saw this in one of the examples

Can I suggest you book an appointment with an optometrist?

Groove: Can I suggest you book an appointment with an optometrist?

ok different version of my code, now can you help me?

  • Created on Nov 18 2015 */

// initial variables int pin1status=0; // pin numbers const int ARD1P811=11; const int ARD1P812=12;

// status notifications String statusok="Port is OK"; String statusfault="Port is bad";

void setup() { // initialize the ports status pinMode(ARD1P811,INPUT); pinMode(ARD1P812,OUTPUT); }

void loop() { // run the program and check the ports pin1status=digitalRead(ARD1P811); if (pin1status==HIGH){ // Display OK

} }

can you help?

can you help?

Sure. What do you need help with?

You posted some code. You didn't say if there was a compilation problem, so I'll assume that it at least compiles. It does something. You didn't say what it does. You expect it to do something. You didn't say what.

Makes it REALLY hard to help you.

PaulS: Sure. What do you need help with?

You posted some code. You didn't say if there was a compilation problem, so I'll assume that it at least compiles. It does something. You didn't say what it does. You expect it to do something. You didn't say what.

Makes it REALLY hard to help you.

i set the port 11 as input and port 12 as output and i want to get some indication when port 12 recive "HIGH". on the arduino i simply place a wire between them.

if i understand you correctly you want me to use the serial port,

Only to see the output when the input pin status changed.