DynamicModule[{n = 20},
Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}],
Dynamic[Legended[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
{True -> Red, False -> Green}] ],
ChartStyle -> {Green, Red}] &@
Tally@Sort@RandomChoice[Tally@RandomChoice[{True, False}, n],
SwatchLegend[{Green, Red}, {False, True}]]]}]]
Alternatively (thanks: Brett Champion):
DynamicModule[{n = 20},
Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}],
Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
{True -> Red, False -> Green}]],
ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
Tally@Sort@RandomChoice[Tally@RandomChoice[{True, False}, n]]}]]