user34001: Code C for PIC16F887, I want to be able to try this code in ATMEGA328, but I do not know how, I do not know the outputs of the pic, that is, none of the pic I know.
Thank you for helping me. Grateful.
/*
Universidad del Azuay
Microcontroladores
Proyecto Piano
Autores: Juan Pablo León, Santiago Vazques
Tutor: Ing. Kenneth Samuel Palacios Baus
Fecha: 2 de enero de 2015
*/

//Declaración de Funciones
void ndo(); //Nota Do
void sdo(); //Nota Do Sostenido
void nre(); //Nota Re
void sre(); //Nota Re Sostenido
void nmi(); //Nota Mi
void nfa(); //Nota Fa
void sfa(); //Nota Fa Sostenido
void nsol(); //Nota Sol
void ssol(); //Nota Sol Sostenido
void nla();  //Nota La
void sla(); //Nota La Sostenido
void nsi(); //Nota Si
void ndo2(); //Nota Do

//Programa Principal
void main (){
osccon=0x77; //Ocilador de 8bits interno del PIC16f887

TRISC=0XFF; //Puerto C habilitamos como entrada  para las notas normales
PORTC=0;;

TRISB=0XFF; //Puerto B habilitamos como entrada para los sostenidos
PORTB=0;

TRISD=0X00; //Puerto D habilitamos como salida para el sonido del parlante
PORTD=0;

ANSELH = 0x00;
ANSEL=0x00;      // Bits AN6:AN0 como E/S digital.

    while(1){


        PORTB=0xFF;  // 255   11111111
        switch(PORTB)
        {
               case  0b00000001: sdo();  break;  //#Do
               case  0b00000010: sre();  break;  //#Re
               case  0b00000100: sfa();  break;  //#Fa
               case  0b00001000: ssol(); break;  //#Sol
               case  0b00010000: sla();  break;  //#La
        }


        PORTC=0xFF;  // 255   11111111
        switch(PORTC)
        {
               case  0b00000001: ndo();  break;  //Do
               case  0b00000010: nre();  break;  //Re
               case  0b00000100: nmi();  break;  //Mi
               case  0b00001000: nfa();  break;  //Fa
               case  0b00010000: nsol(); break;  //Sol
               case  0b00100000: nla();  break;  //La
               case  0b01000000: nsi();  break;  //Si
               case  0b10000000: ndo2(); break;  //Do
        }
    }

}

void ndo(){      //Do
        PORTD=1;
        delay_us (1911);
        PORTD=0;
        delay_us (1911);
}

void sdo(){      //#Do
        PORTD=1;
        delay_us (1804);
        PORTD=0;
        delay_us (1804);
}

void nre(){     //Re
        PORTD=1;
        delay_us (1702);
        PORTD=0;
        delay_us (1702);
}

void sre(){     //#Re
        PORTD=1;
        delay_us (1607);
        PORTD=0;
        delay_us (1607);
}

void nmi(){     //Mi
        PORTD=1;
        delay_us (1517);
        PORTD=0;
        delay_us (1517);
}

void nfa(){     //Fa
        PORTD=1;
        delay_us (1432);
        PORTD=0;
        delay_us (1432);
}

void sfa(){     //#Fa
        PORTD=1;
        delay_us (1351);
        PORTD=0;
        delay_us (1351);
}

void nsol(){    //Sol
        PORTD=1;
        delay_us (1276);
        PORTD=0;
        delay_us (1276);
}

void ssol(){    //#Sol
        PORTD=1;
        delay_us (1203);
        PORTD=0;
        delay_us (1203);
}
void nla(){     //La
        PORTD=1;
        delay_us (1136);
        PORTD=0;
        delay_us (1136);
}

void sla(){    //#La
        PORTD=1;
        delay_us (1121);
        PORTD=0;
        delay_us (1121);
}

void nsi(){    //Si
        PORTD=1;
        delay_us (1012);
        PORTD=0;
        delay_us (1012);
}

void ndo2(){   //Do
        PORTD=1;
        delay_us (955);
        PORTD=0;
        delay_us (955);
}

Code file taken from this video: https://www.youtube.com/watch?v=2jVZnKjCltw

user4143: There are two things you need to learn:

What the instructions in the PIC program mean, and
What the equivalent instructions (or functions for abstracted concepts) are in the Arduino API.

For instance, it looks like you may be making sounds of specific pitches. For that you would replace much of your code with the tone() function.
Reading IO pins would be done with digitalRead(), and pinMode() to set them to INPUT mode.
Basic C constructs like switch, and if() { } else { } etc are the same, but given the abstractions the Arduino API gives you it's probable you'd be using them in different ways anyway.
So in a nutshell: learn what your program is doing, then write the equivalent program for the Arduino.

user20245: No, you can not run Microchip PIC16F887 on an Atmel ATMEGA328 directly.  Any code that does useful work likely interfaces with the "outside world" through the processor's inputs and outputs (ADC, GPIO, ect).  It is very unlikely any two processor designs approach interfacing to the outside world in the same way.
The process of recoding software / firmware to run on different processors is called porting.  It is a time consuming and costly process which is repeated over and over again.  Porting is most often done because people or companies want to use the same software / firmware despite changing hardware due to speed increases, size reductions or cost reductions.

34001: <p>Code C for <strong>PIC16F887</strong>, I want to be able to try this code in <strong>ATMEGA328</strong>, but I do not know how, I do not know the outputs of the pic, that is, none of the pic I know.</p>

<p><em>Thank you for helping me. Grateful.</em></p>

<pre><code>/*
Universidad del Azuay
Microcontroladores
Proyecto Piano
Autores: Juan Pablo León, Santiago Vazques
Tutor: Ing. Kenneth Samuel Palacios Baus
Fecha: 2 de enero de 2015
*/

//Declaración de Funciones
void ndo(); //Nota Do
void sdo(); //Nota Do Sostenido
void nre(); //Nota Re
void sre(); //Nota Re Sostenido
void nmi(); //Nota Mi
void nfa(); //Nota Fa
void sfa(); //Nota Fa Sostenido
void nsol(); //Nota Sol
void ssol(); //Nota Sol Sostenido
void nla();  //Nota La
void sla(); //Nota La Sostenido
void nsi(); //Nota Si
void ndo2(); //Nota Do

//Programa Principal
void main (){
osccon=0x77; //Ocilador de 8bits interno del PIC16f887

TRISC=0XFF; //Puerto C habilitamos como entrada  para las notas normales
PORTC=0;;

TRISB=0XFF; //Puerto B habilitamos como entrada para los sostenidos
PORTB=0;

TRISD=0X00; //Puerto D habilitamos como salida para el sonido del parlante
PORTD=0;

ANSELH = 0x00;
ANSEL=0x00;      // Bits AN6:AN0 como E/S digital.

    while(1){


        PORTB=0xFF;  // 255   11111111
        switch(PORTB)
        {
               case  0b00000001: sdo();  break;  //#Do
               case  0b00000010: sre();  break;  //#Re
               case  0b00000100: sfa();  break;  //#Fa
               case  0b00001000: ssol(); break;  //#Sol
               case  0b00010000: sla();  break;  //#La
        }


        PORTC=0xFF;  // 255   11111111
        switch(PORTC)
        {
               case  0b00000001: ndo();  break;  //Do
               case  0b00000010: nre();  break;  //Re
               case  0b00000100: nmi();  break;  //Mi
               case  0b00001000: nfa();  break;  //Fa
               case  0b00010000: nsol(); break;  //Sol
               case  0b00100000: nla();  break;  //La
               case  0b01000000: nsi();  break;  //Si
               case  0b10000000: ndo2(); break;  //Do
        }
    }

}

void ndo(){      //Do
        PORTD=1;
        delay_us (1911);
        PORTD=0;
        delay_us (1911);
}

void sdo(){      //#Do
        PORTD=1;
        delay_us (1804);
        PORTD=0;
        delay_us (1804);
}

void nre(){     //Re
        PORTD=1;
        delay_us (1702);
        PORTD=0;
        delay_us (1702);
}

void sre(){     //#Re
        PORTD=1;
        delay_us (1607);
        PORTD=0;
        delay_us (1607);
}

void nmi(){     //Mi
        PORTD=1;
        delay_us (1517);
        PORTD=0;
        delay_us (1517);
}

void nfa(){     //Fa
        PORTD=1;
        delay_us (1432);
        PORTD=0;
        delay_us (1432);
}

void sfa(){     //#Fa
        PORTD=1;
        delay_us (1351);
        PORTD=0;
        delay_us (1351);
}

void nsol(){    //Sol
        PORTD=1;
        delay_us (1276);
        PORTD=0;
        delay_us (1276);
}

void ssol(){    //#Sol
        PORTD=1;
        delay_us (1203);
        PORTD=0;
        delay_us (1203);
}
void nla(){     //La
        PORTD=1;
        delay_us (1136);
        PORTD=0;
        delay_us (1136);
}

void sla(){    //#La
        PORTD=1;
        delay_us (1121);
        PORTD=0;
        delay_us (1121);
}

void nsi(){    //Si
        PORTD=1;
        delay_us (1012);
        PORTD=0;
        delay_us (1012);
}

void ndo2(){   //Do
        PORTD=1;
        delay_us (955);
        PORTD=0;
        delay_us (955);
}
</code></pre>

<p>Code file taken from this video: <a href="https://www.youtube.com/watch?v=2jVZnKjCltw" rel="nofollow noreferrer">https://www.youtube.com/watch?v=2jVZnKjCltw</a></p>
 4143: <p>There are two things you need to learn:</p>

<ol>
<li>What the instructions in the PIC program mean, and</li>
<li>What the equivalent instructions (or functions for abstracted concepts) are in the Arduino API.</li>
</ol>

<p>For instance, it looks like you may be making sounds of specific pitches. For that you would replace much of your code with the <code>tone()</code> function.</p>

<p>Reading IO pins would be done with <code>digitalRead()</code>, and <code>pinMode()</code> to set them to INPUT mode.</p>

<p>Basic C constructs like <code>switch</code>, and <code>if() { } else { }</code> etc are the same, but given the abstractions the Arduino API gives you it's probable you'd be using them in different ways anyway.</p>

<p>So in a nutshell: learn what your program is doing, then write the equivalent program for the Arduino.</p>
 20245: <p>No, you can not run Microchip PIC16F887 on an Atmel ATMEGA328 directly.  Any code that does useful work likely interfaces with the "outside world" through the processor's inputs and outputs (ADC, GPIO, ect).  It is very unlikely any two processor designs approach interfacing to the outside world in the same way.</p>

<p>The process of recoding software / firmware to run on different processors is called <a href="https://en.wikipedia.org/wiki/Porting" rel="nofollow noreferrer">porting</a>.  It is a time consuming and costly process which is repeated over and over again.  Porting is most often done because people or companies want to use the same software / firmware despite changing hardware due to speed increases, size reductions or cost reductions.</p>
