I was chatting with our neighbor and after some long talking, I found out that he has a Commodore 64. I'd love to test it, however I'm not sure how to power it.
How can I power a C64?
The Commodore 64 requires a power supply that provides both 9V AC and 5V DC.
If you're interested in building your own, the power supply has a male circular 7 pin DIN connector. Pins 1-3 are ground (pin 2 is the 5V ground), pin 4 is either unconnected or +5V, depending on the version, pin 5 is +5V, and pins 6 and 7 are 9VAC. (source)
Do not use an original Commodore 64 power supply, especially if it has not been tested. They're prone to fail, and when they do, they'll take the C64 with it. But if you do intend on using one of these power supplies, people have developed hardware that go between the Commodore 64 and power supply and can protect the C64 from power supply failure.
The Commodore 128 power supply was better, but the connector is different so the cable will need modifications or an adapter.
If you find two wall-wart power supplies that provide the required currents, you can solder them to the correct DIN connector.
In Poland there was the
Commodore & Amiga magazine in 1992-1995. In it's 7th number (July '92, pages 22-23) there was an article on how to build your own power supply for C64 written by Jerzy Dudek. There is an archive of this magazine at http://stare.e-gry.net/czasopisma/commodore-amiga. It's in DjVu format.
If you build your own PS for the commodore 64, I'd recommend you using one of many available AC/DC switched mode power supplies for 5v, for example this one https://octopart.com/eps-15-5-mean+well-26613044 or any alike. They are light, small and cool under full load, unlike 7805-based scheme in the neighbouring answer.
9V AC power supply has to be floating with regard to 5v supply, so the simplest way is to use any of the available compact conventional 50Hz or 60Hz transformers. If the transformer available has slightly greater output voltage, you can try to unwind secondary winding to the required level, since the secondary winding is usually accessible. It makes sense also to connect primary winding of the transformer after the input filters in your AC/DC 5v power supply or just use additional input filters, as to lower the sensitivity to the noise coming from the power socket.
While I agree completely with some of the answers posted above about using a single transformer to get the 9VAC followed by a bridge rectifier a SMPS to get the 5VDC lines in a single circuit is technically the best solution, it is not a simple or inexpensive solution, requiring knowledge of power electronics and possibly PCB layout, and some time between design and getting your supply working. You can always buy custom made power supplies like these that will run you ~$80-$120 + shipping, but you'll likely have to wait for international shipping or wait for the custom supply to be built for you then shipped.
If you're looking to get your C64 up and running quickly and with minimal design knowledge required, you should go with a simpler setup involving using two existing wallwart type supplies to get the 9VAC@1A and the 5VDC@1.5-2A voltages which you an then wire up to our own cable to a 7-pin DIN connector. For the 9VAC you can use a pre-built 120VAC-9AC @1A wallwart. For the 5VDC, a common smartphone usb charger employing a SMPS that supplies 1.5-2A (depending on the modern accessories you intend to connect to your c64 which may exceed the original 1.5A spec by the original power supply). I followed suggestions on http://dannygalaga.com/c64.html who describes how to make the cable housing for such a power supply. Then located an old android charger rated for 2A and got a USB Type-A Male to 2.5mm barrel connector male cable, a 120VAC-9VAC@1.5A with 2.1mm barrel connector male, a bag of cheap 2.1mm female barrel connectors, a 7-pin din connector, some AWG 22 wire, and heat shrink tubing.
Using this method I was able to put together a functional power supply for my c64 with parts I mostly sourced locally or got quickly thorough amazon and built the supply for ~$22. I was able to assemble the supply cable in around half an hour with minimal issues. If you connect everything correctly your connector should look something like this power-supply cable adapter for c64. It should be noted though that there are some concerns in the community about there potentially being ripple on the supply due to the to separate supplies not having a fused ground inside the supplies themselves (like you would get from having a single transformer design), but the grounds are fused within the c64 motherboard's power supply circuitry and the stead-state voltages within the c64 are all stable matching expected inputs to the chips on board. Sometime soon I'll do some analysis of the power characteristics of this dual-supply design using a scope and post back details on if electrically non-negligible ripple-issues.
Some parts that I used which may be helpful: