// 2002.7.31 小山智史(弘前大学) // タッチスイッチにn秒タッチし続けた時に2度チャイムを鳴らすプログラム // nはプリセットスイッチを押し続けることで1〜7秒の設定ができる(デフォルトは3) #include #include #include #include #include #include uint8_t c_1ms, c_25us, tsw, psw, T; prog_int C[]={ 11364, 10124, 9019, 8513, 7584, 6757, 6020, 5682}; //f: 440 494 554 587 659 740 831 880 SIGNAL(SIG_OUTPUT_COMPARE1A){ outp(inp(PORTB)^0x08,PORTB);} // Alt Bzz SIGNAL(SIG_OVERFLOW0){ // 25.6 us sync if(++c_25us>=39){ // 1 ms sync c_25us=0; c_1ms++; // for t_1ms function if(bit_is_clear(PIND,0)) tsw=100; else if(tsw>0) tsw--; if(bit_is_clear(PINB,7)) psw=100; else if(psw>0) psw--; } } void t_1ms(unsigned char t){ for(c_1ms=0;c_1ms=10){T=t/10; eeprom_wb(0,T);} settone(0); return; } if(t%10==0) settone(t/10); else settone(0); t_1ms(100); } t_100ms(10); // wait 1 sec while(psw>0); } void select(){ uint8_t t; for(t=0;t0); } int main(void){ uint8_t t, i, mode; // PORTB/PINB PORTD/PIND outp(0xf7,PORTB); outp(0x7e,PORTD); // uuuu0u1u xuuuuuux outp(0x0a,DDRB); outp(0x00,DDRD); // ixxxoxox xxxxxxxi c_25us=0; outp(0x01,TCCR0); // CK0 = 0.1 us __outw(0,TCNT1L); // TCNT1=0 outp((1<=8) T=3; t_100ms(1); for(;;){ if(psw>0) preset(); if(tsw>0) select(); } }