Arduino Digital out to second Arduino Digital in

Hi folks,

I'm new to programming, just thought id get that out there beforehand :joy:, I'm trying to use pins 4 and 5 as digital outputs on 1 Arduino(1) which trigger pins 4 and 5 digital inputs on a second Arduino(2). Both Arduinos are derived from the same 5v supply.I have fitted a 10k resistors on each link of the 2 connections between ,i'm not sure it need these, but does that sound like the right configuration? I've looked at a few tutorials which show the 5v out and back via switch or button on a single arduino, but I'm wondering if the 5v digital input has to derive from the the device been controller (2) ie not coming from (1) to (2) :man_shrugging:.

Or has anyone seen examples of this kind of arrangement.

Cheers folks.

Have you connected the grounds?

(This isn't an appropriate topic for this forum section - could you use the flag icon to attract the attention of a passing moderator?)

You can safely make the connections directly between the Arduinos. No resistors needed. They also need a common GND connection which, depending on how the Arduinos are powered, may already exist but I suggest that you connect the GNDs of the 2 Arduinos in any case

Please post your code for each of the Arduinos

I have moved the topic to somewhere more appropriate but we don't know yet whether this is a hardware or software problem

The reason to use 1k series resistors between the two is anxiety regarding the remote possibility that the pins on both might be set as OUTPUT with conflicting HIGH and LOW levels.

Probably improbable.

Most certainly the grounds of the two must be reliably joined. Otherwise you would need opto-isolators.

Always the critical question: Why would you ever want to use two Arduinos?

Ah i did wonder if that question might get asked.. well I have a Arduino running a bar serving program which is getting there (with help), I wanted to run some fast LED and then thought about switching different lights at different stages of the process, ie serving drinks/finished/waiting etc. given my rubbish knowledge I thought using pin out on the first Arduino (1) to drive the fast LED program on the second sounded there simpler route for me...

So at the moment i'm using a HM10 on Arduino (1) to trigger pin 5 on Arduino (2). via the BLExR app, the fast LED starts a single cycle then stops regardless of HIGH or LOW pin state.

Obviously to keep it simple for my brain i'm just playing with PIN4 ( then hopefully expand to PIN5 and 6 lighting scenes)

@Paul_B I'm currently using 10k resistor and have tried without any, also linking the grounds seems to have the same results

Does that make sense? :man_shrugging:

Thanks for ya help folks

#include <FastLED.h>

#define NUM_LEDS  11
#define LED_PIN  3 

CRGB leds[NUM_LEDS];


uint8_t hue = 0;


const int waitingLedPin = 5;
const int dispenceLedPin = 6;
const int drinkReadyLedPin = 7;

int waitingLedPinContact=0;
int dispenceLedPinContact=0;
int drinkReadyLedContact=0;

void setup() {


FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(100);

pinMode(waitingLedPin, INPUT);
pinMode(dispenceLedPin, INPUT);
pinMode(drinkReadyLedPin, INPUT);


Serial.begin(57600);

 
}

void loop() {

waitingLedPinContact=digitalRead (waitingLedPin);


if (waitingLedPinContact == HIGH)
do {

   for(int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Red;
    FastLED.show();
    delay(100);
    leds[i] = CRGB::Black;
   }}
 while (waitingLedPinContact == LOW);
 
  

if (waitingLedPinContact == LOW) {

 FastLED.clear();
 FastLED.show();

   }
}

That sounds like a great project for ONE arduino. The bartending sketch knows when it is changing stages, so rather than signal the other arduino, just have it set the LEDs directly. MUCH easier.

@blh64
Im probably wrong but the Fast LED stops running whilst the barbot is serving ie the arduino only does 1 think at at time, hence the second one to keep the light show on whilst serving. so i'm just trying to figure out the switching / programming bit

thanks

True, but it can to a small sliver of one thing, switch to the next, etc. so fast that us slow humans think it is doing many things at the same time. If fact, it is a common issue, easily solved with a bit of proper code structure.

several things at the same time

I did actually read that tutorial before opting for the second oddly :joy: looked far beyond my current skill level. and if you look at my code you'll see "prober code structure" is the least of my troubles​:joy:.

Generally, you only use a second Arduino if you're forced to. It just adds pain and complexity. Worse, usually the requirements on such a project evolve and you find yourself fighting with the communications protocol between controllers rather than your core functions.

If you need more speed or pins, just get a better microcontroller like a Teensy for example.

And that is why it is so important to ask the question. :astonished:

So now i know the posts in the wrong place, to use a 1 k resistor but its fine without, use a Teensy instead of 2 Arduinos and it import to ask questions :joy:. happy days.

Or even just use a single Arduino.

Not wanting to sound ungrateful for the advice but seems to be lots of comments on swapping hardware ,OK point taken but that ain't happening at this stage, all the bits are in, wired, powered etc, any chance theres any help on the questions asked i'm guessing my code is probably not right and maybe the problem?. its not a big issue I can just leave the second Arduino (2) doing a Fast LED full time and not bother with the triggering from (1). Thought I'd ask the question and go fancy

Cheers

You have two Arduinos that run a sketch; you only show one of them.

Yes, this is possible. Should actually be quite simple to be honest. The only challenge will be in making sure that you have the right interface design - for instance, on the "input" Arduino, is the input pulled high or low when the other Arduino is not "driving" it? Then make sure the driving Arduino drives it the proper polarity to that interface circuit. If you are reading the input expecting that a 1 means the driving Arduino is asserting that pin, then put a 1-10k resistor from that line to ground (a pull-down resistor) near the input Arduino pin. The other Arduino writes a 1 to that pin to assert the signal to the other, and write a 0 when not asserting it. You could do that opposite with a pull-up, assuming that writing a 0 is what is needed to signal activity to the input Arduino.

In trying to understand why everyone wants you to revert to a single Arduino, that's simply because they are used to helping relatively inexperienced people solve their higher-level problem and work on that high-level solution most of the time. In your case, you aren't asking what's the best way to architect a solution, but simply how to use simple, digital I/O between two Arduinos, and there is nothing improper about doing that if you want to.

The other Arduino will always be outputting either 0V or 5V if its sketch is written correctly so it will always be "driving" the input pin which will never be floating at an unknown voltage

Because perhaps, that is good engineering advice? :roll_eyes:

It is commonly referred to as "creative head-banging". :rofl:

Advice that solves the problem you interpret but not the actual problem is not actually good advice because it is not helpful.

@ssabin It is helpful when you reply to a post if you use the Reply to this post button


so that it is obvious which post you are replying to