Need suggestions for a project

Yes that would work but you need an analogue input and pull up resistor.