Upload
andres-gavilanes
View
220
Download
0
Embed Size (px)
Citation preview
8/16/2019 Ejemplos de microcontroladores
1/2
#include #use delay(clock=4000000)#fuses HS,NOWDT,NOPUT,NOPROTECT#byte trisb=0x86 //Variable TRISA en 86h#byte portb=0x06 //Variable PORTA en 06hvoid main (){//bit_clear (OPTION_REG,7); //Habilitacion Pull-up
bit_set(TRISB,0); //B0 como entradabit_clear(TRISB,1); //B1 como salidabit_clear(PORTB,1); //Apaga el ledwhile (1){ if (bit_test(portb,0)==1) //Si RB0 es 1, apaga el LED bit_clear(portb,1); else
bit_set(portb,1); //Si RB0 = 0 , enciende el LED
}}+
----------------------------------------------------------------------#include #use delay(clock=4000000)#fuses HS,NOWDT,NOPUT,NOPROTECT//#byte trisb=0x86 //Variable TRISA en 86h//#byte portb=0x06 //Variable PORTA en 06h#use standard_io(B)void main(){port_b_pullups (TRUE);output_low(PIN_B1);while (1){if (input(PIN_B0)==1)
output_low(PIN_B1);elseoutput_high(PIN_B1);}}------------------------------------------------------------------#include #use delay(clock=4000000)#fuses HS,NOWDT,NOPUT,NOPROTECT//#byte trisb=0x86 //Variable TRISA en 86h//#byte portb=0x06 //Variable PORTA en 06h#use fixed_io(b_outputs=pin_b1) //indica el terminal de salida
void main(){port_b_pullups (TRUE);output_low(PIN_B1);while (1){if (input(PIN_B0)==1)output_low(PIN_B1);elseoutput_high(PIN_B1);}}----------------------------------------------------------------------------#include
#use delay(clock=4000000)#fuses HS,NOWDT,NOPUT,NOPROTECT#define TRISB (int*) 0x86
8/16/2019 Ejemplos de microcontroladores
2/2
#define PORTB (int*) 0x06#define OPTION (int*) 0x81void main(){*option &=0b01111111;*trisb=0x01;*portb=0x00;while(1)
{if (*portb & 0x01)*portb=0x00;else*portb=0x02;}}
--------------------------------------------------------------------------------
#include #use delay(clock=4000000)
#fuses XT,HS,NOWDT,NOPUT,NOPROTECT#use fast_io(B)#use fast_io(A)
byte CONST DISPLAY[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6};void main(){ byte ud=0,dec=0; SET_TRIS_B(0x00); SET_TRIS_A(0x00); OUTPUT_B(0); for(;;){ for(dec=0;dec