Hi, is this schematic possible? Each time one arduino board will controll the led. The other one it stays off. When I switch to the 2nd arduino, the first one gets out of power. So is this safe or will it burn the pins?
Not a good circuit.
The led will be safe, protected by the resistor.
The Arduino could damage each other..
If both Arduino are powered and the pin is HIGH on the first Arduino and LOW on the second Arduino, a short circuit will happen and burn both pins.
If only one Arduino is powered, if it's pin is HIGH, it will power the second Arduino through its pin by a method called "parasitic powering". This is also dangerous and could burn both Arduino
You may be able to make this circuit work with 2 extra diodes.
Two extra diodes will work fine - one in series with each output pin in case that is not obvious.
Alternative is to control the LEDs by writing the pin HIGH and switching pinMode between OUTPUT to light the LED and INPUT to not light it (much - INPUT mode and HIGH enables the internal pull-up which will show some glow in the LED).
1N4001 would be fine. Can't understand why you say it would be too large. Your circuit already contains 2 Arduino Uno, 1N4001 is tiny by comparison.
Now the more important question: why are you using 2 Arduino? When beginners say that they want to use more than one Arduino in a circuit, it is almost always the wrong decision.
When beginners say that they want to use more than one Arduino in a circuit, it is almost always the wrong decision.
Pretty much always!
You picked it before me!
You still have not explained why you are using a UNO and a Mega. Nor indeed, a reason for requiring to use a Mega. If you are mounting these as “daughterboards” to your own PCB, then a UNO is quite inappropriate - you should be using a Nano.
You refer to - or imply - “turning on” each device for a specific purpose. Since this is all mains powered, there is no reason not to have them continuously powered. It would in fact, be far more sensible to have one unit only, performing both functions as there would then be no problem coordinating their alternate operations. It is even more absurd if you are duplicating the functions to drive the same five bells.
This sounds very much as if your project is simply poorly thought out and you do not understand the basics of coding in order to combine two “sketches” together.
Well, as I say, that is what this forum here is for!
I am wondering from where you have obtained the code you are using - if you "don't know much about coding" you have presumably obtained it from somewhere but we do not know whether that source is competent at concise coding or not.
Certainly, combining the code is the sensible approach rather than muddling about with two different devices.
Why did you opt to use the Uno to send a signal every hour? If the Uno is only generating the hourly signal, would it not have been neater to use an RTC like a DS3231 connected to the Mega and let the mega read that clock and determine when it needs to ring the bell?
If the sketch of the uno is combined with mega's then it may send the signal let's say at 5 o'clock
Why would it?
I don't realy know how to combine the two sketces.
So with my little experience with coding i chose to have to different boards in order to use each one of them whenever i want.
What you want to do is almost trivial, ask here how to do it.
Using two Arduinos for this is almost a criminal waste of hardware.
I'm out of it unless he wants a serious discussion.