Generalizing main.cpp to remove pin dependency