Paso 13: Copiar y pegar
Copie y pegue el siguiente código en tu archivo principal (sobrescribiendo lo que ya está allí).
// This code is specific to the DP32, and will not work on any other chipKIT device. // For instructions on how to change this code to suit other chipKIT boards, check the // Digilent blog for my post on how this code works. #include <stdio.h> #include <stdlib.h> #include <p32xxxx.h> // Main is where our program starts int main(int argc, char** argv) { // This code only gets executed once // It's the same as our setup() function in Arduino int i = 0; // Generic index value // Set pin 13/RB02 to output TRISBbits.TRISB2 = 0; // This is functionally the same as the pinMode() function in Arduino // This while loop runs forever. // It's the same as our loop() function in Arduino. while(1) { // Read the logic level of pin 13/RB0 // Invert that, and set its logic level to the opposite of what it was LATBbits.LATB2 = ~PORTBbits.RB2; // This is a combination of digitalRead() and digitalWrite() in Arduino. // Delay for some time. // We're cheating and not using timers, because those are complicated, // so we don't know the exact time this will delay for. for(i = 0; i < 10000; i++); } return (EXIT_SUCCESS); }
Que no explican lo que hace este código aquí, pero si te interesa y sería como una explicación completa de lo que está sucediendo, estoy escribiendo un blog post para el blog de Digilent que entra más profundidad.