IR Remote Control Card with C - Help Needed - Atmega 8

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys,

I've started to take MicroProcessors course and sadly getting nothing from it, yet we need to complete a project.

Items to be used : 

4 button Remote Control
(ON/OFF , Up, Down , 1to3)

I need to design and control 4 leds with the remote control.

1st led : Showing ON/OFF situation.
2nd led : 1st level
3rd led : 2nd level
4th led : 3rd level

My control card needs to control these leds. When pressed ON/OFF on remote control, 1st led will light. After that when i increase the level by up  button it will go upto 4th led and light them with order.

When i decrease from IR remote control, it needs to go lower on leds.

Last button on remote control, will be max/min function. If the level is at 1, it will take it to 3rd, if it's at 3rd it will take it to 1st.

I have this code that i can use, but it is for PIC and i have no idea how to revert it and use for Atmega8. If you can help or at least give me a direction, it'd be appreciate.

 

Thanks in advance.
 

unsigned short FlowPL, sens, CommMode, CCnt, RCVT[5];


////////////////////XXXXXXXXXXXXXXXXXXX---!!!KESME
void interrupt() {
        if (intcon.INTF) { // kumanda algılama
                intcon.INTF = 0;
                FlowPL = TMR0;
                TMR0 = 0x00;
                intcon.INTE = 1;
                INTCON.T0IF = 0;
                if (FlowPL > 155) {CommMode = 0; CCnt = 0;}

                if (CommMode > 0) { CCnt++; RCVT[CommMode] = RCVT[CommMode] >> 1;
                        if (FlowPL < 6) RCVT[CommMode].F7 = 0;
                        if (FlowPL > 6) RCVT[CommMode].F7 = 1;
                }
                if (CCnt > 7) {CCnt = 0; CommMode++; RCVT[CommMode] = 0;}

                //if ((CommMode > 2) & (RCVT[1] != 3) & (RCVT[2] != 224)) {CommMode = 0; CCnt = 0;} //Check User Code
                if (CommMode > 3) {CommMode = 0; sens.f0 = 1;}
                if (FlowPL > 47) {CommMode = 1; CCnt = 0; RCVT[CommMode] = 0;}
        }
}
////////////////////MMMMMMMMMMMMMMMMMMMMM---!!!MAİN
void main() {
        OSCCON = 0b01101010;
        ANSELA = 1;
        PORTA  = 0;
        TRISA  = 0b00010011;

        ANSELB = 0;
        ADCON1 = 0b01100000;
        PORTB = 0;
        TRISB = 1;           // PORTB is output
        PORTB = 0b11111000;

        sens = 0;

        RCVT[0] = 1;
        Delay_ms(1800);
        PORTB = 0;

        OPTION_REG = 0b00000111;  // Timer0 settings
        TMR0 = 0x00;              //Timer0 sıfırla

        T2CON = 0b01111110;  //Timer2 Setting
        intcon = 0b01000000; //Kesme Ayarları

        OPTION_REG.F7 = 1;  //WPUEN disablet (weak Pull Up)
        OPTION_REG.F6 = 0;   //INTEDG: Interrupt Edge Select bit
        intcon.INTF = 0;
        intcon.INTE = 1;
        intcon.GIE = 1;

        UART1_Init(9600);               // Initialize UART module at 9600 bps
        Delay_ms(100);                  // Wait for UART module to stabilize

        UART1_Write_Text("Start");
        UART1_Write(10);
        UART1_Write(13);

        ////////////////////////////////////////////////////////////////////////////////
        do {

                if (INTCON.T0IF) {    // KUMANDA TIME OUT
                        TMR0 = 0x00;
                        CCnt = 0; CommMode = 0;
                }


                if (sens.f0) { sens.f0 = 0;

                        if (RCVT[3] == 96) {   //ON OFF

                        }

                        if (RCVT[3] == 98) { //KADEME AZALTMA

                        }
                        if (RCVT[3] == 97) { //KADEME ARTIRMA

                        }

                        UART1_Write(RCVT[1]);
                        UART1_Write(RCVT[2]);
                        UART1_Write(RCVT[3]);
                        UART1_Write(RCVT[4]);
                        UART1_Write(RCVT[5]);
                        UART1_Write(RCVT[6]);
                        UART1_Write(RCVT[7]);
                        //UART1_Write(CRC);
                        //UART1_Write(RCVT[9]);
                        //UART1_Write(RCVT[10]);
                        //UART1_Write(RCVT[11]);
                        //UART1_Write(RCVT[12]);
                        //UART1_Write(RCVT[13]);

                }



        } while(1);    // endless loop

}//~!}

 

Last Edited: Tue. Apr 28, 2015 - 12:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

OP said "I've started to take MicroProcessors course and sadly getting nothing from it, yet we need to complete a project."

 

With any luck it's not too late to drop the class and get your money back, then pick another career path! 

 

PIC code will not compile on an AVR, do some more googling and see what you come up with.  

 

 

 

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EgeDemir wrote:
I've started to take MicroProcessors course and sadly getting nothing from it

That, surely, is something you need to take up with the course directors and/or tutors.

 

What stage, exactly, have you reached in this course? Receiving & decoding IR remote control signals is hardly beginner's stuff!

 

Then again, it is not new or unusual;  there is plenty of material available on the interwebs - not least in Atmel's own extensive list of application notes: http://www.atmel.com/devices/atm...