Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Moottorin tehon nosto- ja laskuohjelma by Anton Saarinen, S13VSTG1
- #ifndef F_CPU
- #define F_CPU 16000000UL // 16 MHz clock speed
- #endif
- #include <avr/io.h>
- #include <util/delay.h>
- int main(void)
- {
- ASSR = 0x00;
- TCNT2 = 0x00;
- OCR2 = 0x00;
- TCCR2 = 0x66;
- DDRD = 0xFF;
- int d=0;
- while(1) // Loputon looppi
- {
- for(d=0; d<255; d++) // Nostaa tehoa kunnes maksimissa
- {
- OCR2=d;
- _delay_ms(50); // Viive tehon noston välillä
- }
- for(d=255; d>0; d--) // Laskee tehoa kunnes nollassa
- {
- OCR2=d;
- _delay_ms(50); // Viive tehon laskun välillä
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement