Sorry about the terse nature of the previous message but I was on my 'phone at the time.
A state machine is a "posh" name for a program that is in one of several states at any one time. In your case that would be either displaying the main screen or the sub screen. Two states.
Imagine that you have s variable named currentState the value of which can be 0 or 1. When it is 0 the main screen is displayed and the program tests for a button press. When the button press is detected change currentState to 1 and display the sub screen and detect a button press to change back to state 0.
You can use if for this as in this pseudo code
if (currentState == 0)
{
//code here to display main screen and detect button press
if (button becomes pressed)
{
set currentState to 1
}
else
if (currentState == 1)
{
//code here to display sub screen and detect button press
if (button becomes pressed)
{
set currentState to 0
}
}
Personally I favour using switch/case instead of if/else but you may be more familiar with the former