There are a lot of sketches that other people have written that work fine on the Mega. Just not any of the Firmata variations. Those, of course, will work on the UNO.
Its fairly simple to control the mega over serial,
simply if serial == this then do that
either have different commands for specialized functions or convert it directly to a command,
I have my mega set to receive a 4command byte command over serial,
first two bytes declare what pin
Third declares input or output
fourt declares on or off, analog or digital
and it works with any program that can use serial