Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <xc.h>
- //Codi 1
- void main(void) {
- //Config
- //Set as digital port
- ANSELA = 0x00;
- ANSELB = 0x00;
- //Set RA0 as output
- //TRISA = 0x00;
- TRISAbits.RA0 = 0;
- //Set RB0 as input
- TRISBbits.RA0 = 1;
- while (1) {
- PORTAbits.RA0 = PORTBbits.RB0;
- }
- }
- //Codi 2
- int apretat = 0;
- void main2(void) {
- //Config
- //Set as digital port
- ANSELA = 0x00;
- ANSELB = 0x00;
- //Set RA0 as output
- //TRISA = 0x00;
- TRISAbits.RA0 = 0;
- //Set RB0 as input
- TRISBbits.RA0 = 1;
- while (1) {
- if (!PORTBbits.RB0) {
- if (apretat) {
- apretat = 0;
- PORTAbits.RA0 = !PORTAbits.RA0;
- }
- }
- else {
- apretat = 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement