pwm for arduino

Discussion in 'Embedded Systems and Microcontrollers' started by haneys, May 25, 2012.

  1. haneys

    Thread Starter New Member

    May 25, 2012
    hi.. im a very beginner to arduino. i need ur help, and i think its just simple for those who know about arduino.. i have the code as below, which is for ATmega. can anyone help me to convert the code into arduino 0023 format.. help me please..
    many2 thankz..

    #include <avr/io.h>
    #define F_CPU 16000000UL //set 16mhz crystal

    int main (void)
    DDRD |=0xFF;

    //initialization for timer1
    TCCR1A |= 1<<WGM11 | 1<<COM1A1 | 0<<COM1A0; // COM1A1=1,COM1A0=0,FOR NON INVERTED MODE...1:1 FOR INVERTED MODE
    TCCR1B |= 1<<WGM12 | 1<<WGM13 | 1<<CS10 | 1<<ICNC1; //sebelum ni CS10 =1;ICNC1 =1 noise canceller
    ICR1 = 7; //counter value utk 16MHZ

    OCR1A = 3;