Stand in such position so that you have the gate on your left.
Now you have to set the right combination of levers three times.
Every combination ends with pressing the switch to the gate.
Library is the first room in the Castle.
It is not big, but there are also no enemies inside.
There are some items here.
A riddle in(1)is about opening the crates to the next area.
After doing that, put every lever on its starting position before pulling it again.
In this location you could find the notes on that combination.
The sequence is:
First: Lever in front down, button.
Second: Right lever down, button.
Third: Both the lever in front and the right lever down, button.