CD control with GPIO

Is there a way to eject a cd with a GPIO function? I am using a mac superdrive. It would be nice to have a physical eject button instead of digging through the menu for eject.

Yes, that is already feasible
If you want to eject a CD drive you will need the “eject” package and command installed (if it isn’t already installed)

sudo apt-get update
sudp apt-get install eject

Then you write a Python (or other language) program that monitors the GPIO pin you are using and calls “eject devicename” when needed (and maybe “umount devicename” first).
eject /dev/cdrom
eject -t /dev/cdrom
import os

os.system("/usr/bin/eject /dev/cdrom")
with command “eject sr0” it opens and with “eject -t sr0” it close

is your superdrive also that loud because it always tries to run at full speed on every track?

check this out :wink:

I can hear it but it’s not that loud. I think the superdrives are pretty quiet to begin with. Thanks for the reply!

Does this still function even tho the super drive is slot loading. No tray to manage

I can eject the cd from the superdrive via the menu, the command is already available in volumio, so it will also work via gpio.

unfortunately my superdrive is very loud
how did you connect yours, i have it with a y-cable, and additional power supply unit

I plugged mine in directly to the pi4. works as long as I don’t connect another high power device. I plan on doing a split power cable since I have a display I would like to use too. I see you can eject from the UI. I have the gpio plugin installed as well as the rotary encoder plug in. I don’t see the option to eject with either.

ok I will try tomorrow without the y cable and power supply.
Maybe I’ll see the eject button because I installed it this way.

CD Player install:
sudo apt-get update
sudo apt-get install sg3-utils -y

when i then insert a cd, the menu for the cd appears in volumio

no i get the menu too. i just want to use a button with a free gpio pin to eject since the superdrive has no buttons