Mario
Mario
h>
#include <delay.h>
//inisialisasi Timer/Counter 1
//Clock source : System Clock/8
//Clock value: 500khz
//mode: phase correct PWM. TOP value = ICR1 value
//TCCR1A=0x82 -> Non-Inverted PWM mode
// OC1A output: clear OC1A on compare match when up counting
//set OC1A on compare match when down-counting
//OC1B otput: Disconnected (normal)
{
if (PINC.0==0) //jika tombol terhubung dengan PC0
{ //ditekan maka motor semakin lambat
delay_ms(100); //berputar sampai berhenti
temp-=0xFF;
if (temp==0xFF01) temp=0x00;
}
if (PINC.1==0) //jika tombol yang terhubung dengan PC1
{ // ditekan maka motor semakin cepat
delay_ms(100); //berputar semapai berputar terus
temp+=0xFF;
if (temp==0x00FE) temp=0xFFFF;
}
OCR1A=temp;
};
}