domingo, 9 de julio de 2017

Programa PIC 18F4550 "Dado"

El programa da numero al azar hasta que se mantiene presionado RA0

Les comparto el codigo en C





#include <18f4550.h>
#fuses XT,WDT,NOPROTECT,NOPUT, NOPBADEN
#use delay(clock= 20000000)
#BUILD(reset=0x2000,interrupt=0x2008)
#ORG 0x0000,0x1fff {}
#include <lcd.c>
#include <stdlib.h>
#include <math.h>
#use standard_io(B)
#use standard_io(A)

void main(){
lcd_init();                          
printf(LCD_PUTC, "Dado");
int8 u, tiempo;
SET_TRIS_B(0x00);
SET_TRIS_A(0x00);
setup_oscillator(OSC_4MHZ);

output_b (0);
srand(6);
 while (true) {
 if (input(PIN_A0)==1)
 {
 tiempo=0;
 while (tiempo<50)
 {
 u=(rand()%(6)+1);
 output_b(u);
 tiempo++;
 delay_ms(200);
}
}
delay_ms(200);
 }

}

Adicional les comparto el diagrama de Proteus


Si tienen alguna duda o necesitan complementos por favor pongan en comentario les apoyare. 

1 comentario:

  1. 3 card poker rules for beginners to master | WKRIT
    For example, you can see that in 바카라 사이트 poker, the hand is the player who is the dealer's first card, and the player's first 바카라 card from each hand. In other words, the player 카지노 is

    ResponderBorrar