updated main_patch

set pinMode automatically thanks to a counter