Switching two contacts with 24VDC potential difference
Welcome to StackExchange SE.You will find many helpful and useful people here and superb technical resources. You and your programming expertise are very welcome here.
With no intention of being rude, I strongly feel that it is worthwhile for you to note that you need to get used to how things are done here. Failure to do this will attract downvotes from people (not usually from me) who have strict ideas re the need to show that you are taking notice of the input that people have taken time to provide.  It is usual for people to make comments and ask questions when what you write is unclear and/or less clear than you may realise.  You need to read and pay attention to answers and comments given. Simply insisting that people do things in the manner that you want them to leads to downvotes and/or people ignoring your questions. 

The answer you wanted 


Was in the very first comment, written very shortly after you posted the question.  
AND also in the 2nd comment posted an hour later. 


For some reason you ignored this answer twice. 

THE ANSWER:

If you had read and noted what JRE says above and looked at the Arduino code on The example page provided you would have seen that to make the relay operate:

JRE:    


You have to connect it to +5V (preferably through a resistor) to make the relay change states. And ...
Follow the links to the examples from that site, and you will find that the code examples provide a logic level 1 to switch the relay on.


ie to turn the relay on you need.


digitalWrite(relay,HIGH);


1e


The relay is turned ed on by a high / +5V / level = 1 signal. 




Switching:

Those relay modules and ones like them are relatively low quality - not utter junk, but also not super high quality. As shown in the photo, the relays used ARE rated for 24 VDC operation, but it is near the upper end of their range. Minimising current surge and anything liable to make them form an arc across the contacts should be avoided. Switching an inductive load at 24 VDC will probably destroy them quickly or immediately. Take due care. Ask if uncertain. 





STYLISTIC WARNING:

The devices shown below are also called "Turnstiles" (despite not turning and not being stylish) by some, and serve much the same purpose as the rotary sort. Attempting to sprint through the open "gate" while pulling an excessively heavy wheeled bag behind can result, should the gate 'shut' just prior to passage, in the puller hitting the gate and folding over it. The following bag if suitably heavy will then do its darndest to push the puller over the barrier. Regardless of whether the transition attempt succeeds or fails, a significant degree of pain will ensue. Not recommended.
[Ask me how I know :-) :-(.]
Knowing why anyone should have this happen will probably require an offlist email :-).