Using an electrical transformer for simple project
Do not connect just any old transformer that you may have laying around up to the AC Mains.

Make sure that the transformer is rated for mains operation. If the unit you have is unlabeled or has no identifying numbers and corresponding data sheet then set it aside.

Safety and protection of your self and the property around you is the primary consideration here. It is far better to obtain correct components than it is to quibble over the cost savings of some piece of surplus junk that you know nothing about.