write code to trip alarm when "no change" in'HB' is detected

i only know

if hb = ‘1’

off counter = 0

on counter ++;

else ‘HB’ = ‘0’

on counter = 0

off counter ++;

}

if(on counter >5) or (off counter >5)

alarm trip

i only know this someone help me please and i use my arduino as a sender while my handphone is a receiver. im using mit app inventor 2