#ifndef F_CPU
#define F_CPU 16000000UL
#endif

#include <avr/io.h>

uint8_t armed=0;
void update_arm(uint16_t throttle, uint16_t sw){
  if(sw>1700 && throttle<1050) armed=1;
  if(sw<1300) armed=0;              // выключатель снял арминг
}
uint16_t motor_out(uint16_t throttle){ return armed ? throttle : 1000; }

int main(void){
  DDRB|=(1<<PB5);
  volatile uint16_t th=1000, sw=1000;
  for(;;){
    update_arm(th, sw);
    if(armed) PORTB|=(1<<PB5); else PORTB&=~(1<<PB5);
    (void)motor_out(th);
  }
}
