0

I am making a peer-to-peer network of initiating devices and a common hub, which controls most of the hardware. It sends a number over Serial to Mega's Serial1 (Mega's Serial is used for communicating to the computer), but as a fallback it initiates a general alarm by sending a 5v signal (using digitalWrite(pin, HIGH)) to the main board. In order to complete the circuit and get the read, how would I do this?

Thanks!

  • what you ask is purpose of a digital pin. to read a state of a digital pin of some other device – Juraj Feb 16 at 6:30
  • 5V is a value of voltage, not a value of current .... please edit the title of your post – jsotola Feb 16 at 19:46
1

Yes of course you can. Better to use digitalRead() than analogRead() however.

You just need to tie the grounds of the 2 Arduinos together, and set up the pin on the Arduino you want to sense the input as INPUT or INPUT_PULLUP. Then do a digitalRead on the pin. It will return LOW if the other Arduino is setting the pin LOW, and HIGH if the other Arduino is setting it HIGH.

And, as Juraj points out in their comment, CMOS devices like Arduinos respond to voltage, not current. Their inputs are capacitive. They react to a voltage potential, not current. (When you initially change a CMOS input from one state to another a small amount of current flows in to change the state of the capacitor and after that the only current that flows is a very tiny amount of leakage current through the capacitor on the input.)

  • Thanks a bunch, I would not have thought of this myself. I'd have gone to the ends of the Earth over-engineering some code to beam signals off the moon and back just to say "HEY" to the other board lmao. – Winter from SYGMAH Feb 16 at 1:40
  • @duncan-c, you should not suggest in an answer on Arduino SE that LOW is false and HIGH is true. – Juraj Feb 16 at 6:33
  • @Juraj, why shouldn't you suggest this? In my experience, we use switches that are normally open when in normal state, so closing them and closing a HIGH voltage would signify the change. – Winter from SYGMAH Feb 16 at 19:25
  • @WinterfromSYGMAH HIGH / true, and LOW / false are different constants, and should not be used interchangeably. Juarj is correct. I edited my post. – Duncan C Feb 16 at 22:10
  • @DuncanC and Juraj, thank you for the clarification and the help – Winter from SYGMAH Feb 16 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.