From Generation II [GSC] onwards, if a Pokémon has more than half of its max HP, its HP bar remains green. If the Pokémon has between one-fifth and half of its HP, the bar will turn yellow (in Generation II, a Pokémon revived to exactly half of their HP will have a green HP bar). If a Pokémon has less than one-fifth of its HP remaining, the bar will turn red...
In RGBY, the color of the HP bar is instead calculated using the width of its fill:
In Generation I, if the HP bar's fill was 27 pixels or wider (out of a total end-to-end length of 48 pixels), it would be colored green; if it was between 10 and 26 pixels, it would be colored yellow; and if it was less than 10 pixels wide, it would be colored red. This means the HP bar turns yellow noticeably earlier than in the later games, or at about 56% of the Pokémon's maximum HP.
I hope this answered your question.