GUIA DE MICROS Y REGISTROS

Page 1

GUIA DE MICROS Y REGISTROS ACTVIDAD UNO PRENDER Y PAGAR UN LED PROGRAMA EN CCS

#include <18f2550.h> //#fuses intxt,nowdt,nomclr,nolvp,noprotect #use delay (clock=8000000) void main (void) { while (true) { output_high(pin_b0); delay_ms(1000); output_low(pin_b0); delay_ms(1000); } }


SECUENCIA PARA ENCERDER 8 LEDS PROGRAMA EN CCS

#include<18f2550.h> //#fuses intxt,nowdt,nolvp,noprotect #use delay (clock =8000000) int X=0,aux[26]; void main(void) { aux[0]=0b00000001; aux[1]=0b00000010; aux[2]=0b00000100; aux[3]=0b00001000; aux[4]=0b00010000; aux[5]=0b00100000; aux[6]=0b01000000; aux[7]=0b10000000; aux[8]=0b01000000; aux[9]=0b00100000; aux[10]=0b00010000; aux[11]=0b00001000; aux[12]=0b00000100; aux[13]=0b00000010; aux[14]=0b00000001;


aux[15]=0b10000001; aux[16]=0b01000010; aux[17]=0b00100100; aux[18]=0b00011000; aux[19]=0b00100100; aux[20]=0b01000010; aux[21]=0b10000001; aux[22]=0b11110000; aux[23]=0b00001111; aux[24]=0b11110000; aux[25]=0b00001111; while(true) { for (x=0;x<=25;x++) { output_b(aux[x]); delay_ms(100); } } }


CONTADOR DE 0 A 9

#include <18f2550.h> //#fuses intxt,nolvp,nowdt,nolvp,noprotect #use delay(clock=8000000) int Display[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; int unidades; void main (void) { port_b_pullups(TRUE); while(true) { for(unidades=0;unidades<10;unidades++) { output_b(display[unidades]); delay_ms(300); } } }


ENCENDER LCD

#include <18f2550.h> //#fuses intxt,nowdt #use delay (clock=8000000) #define use_portb_lcd true #include<lcd.c> void main (void) { setup_oscillator(OSC_8MHz); while (true) { lcd_init(); lcd_gotoxy(2,1); lcd_putc("ELECTRONIK"); lcd_gotoxy(3,2); lcd_putc("sena"); delay_ms(1000); lcd_putc("\f"); } } }


MANEJO DEL CONVERSOR ANALOGO DIGITAL

#include<16f877.h> #device adc=8 //resolucion #use delay(clock=4000000) #define use_portb_lcd true #include<lcd.c> const int escala=255; const float v_max=5; void calcula_voltaje(int val, float&voltaje){ voltaje=(val*v_max)/escala; } void main(void){ int valor; float voltaje; lcd_init(); lcd_putc("\f"); lcd_putc("voltios= "); lcd_gotoxy(15,1); lcd_putc("v"); while(true){ // = for(;;) lcd_gotoxy(10,1); setup_adc(adc_clock_Div_32); setup_adc_ports(An0); set_adc_channel(0); valor=read_adc(); calcula_voltaje(valor,voltaje); voltaje=voltaje*44; printf(lcd_putc,"%1.3f",voltaje); delay_ms(100);}}


ENCENDER UN LEDCON PULSADOR

#include<18f2550.h> //#use delay(clock=8000000) #byte portb=0xf81 #byte porta=0xf80 void main (void) { set_tris_a(0*01); set_tris_b(0*00); portb=00; while (true) { if (input(pin_a0)) { portb=01; } else { portb=00; } } }


CONTADOR DE 0 A 9 CON PULSADOR

#include <18f2550.h> //#fuses intxt,nowdt,nolvp,noprotect // lo de sabilito para poder probarlo en proteus pero si lo voy a quemar tengo que habilitarlo #use delay(clock=8000000) #define use_portb_lcd true #include <lcd.c>

int a,b,c,dato[20]; void main(void){ setup_oscillator(osc_8MHz); {

set_tris_a(0x00); lcd_init(); delay_ms(100); while(true){


if(input(PIN_A1)==1){ a=0; for(a=0;a<=9;){ if(a==10){ break;} lcd_putc("\f Contador \n"); printf(lcd_putc,"%u",a); delay_ms(100); if(input(PIN_A0)==1) { a++; }

} } } } }


ACTIVIDAD DOS REGISTRO DE ALMACENAMIENTO


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.