You are on page 1of 4

CONTROL REMOTO

SIMULACIÓN
C1

22pf
1

U1
X1 13
OSC1/CLKIN RB0/INT
33
CRYSTAL 14 34
OSC2/CLKOUT RB1
35
RB2
2

2 36
C2 RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
22pf 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
R1 23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
10k RC6/TX/CK U3
26 16 8
RC7/RX/DT
19 2 3
RD0/PSP0 IN1 VSS VS OUT1
20 7 6
RD1/PSP1 IN2 OUT2
21 1
RD2/PSP2 EN1
22
RD3/PSP3
27
RD4/PSP4
28 9
RD5/PSP5 EN2
29 10 11
RD6/PSP6 IN3 OUT3
30 15 14
RD7/PSP7 IN4 GND GND OUT4
PIC16F877A
L293D

PROGRAMA

#include <16F877A.h>
//#device ADC=16

#FUSES NOWDT //No Watch Dog Timer


#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18)
used for I/O

#use delay(crystal=4M)
#use fast_io(a)
#use standard_io(b)
#define LED pin_b0
#define LER pin_b1
#define LEA pin_b2
#define LEB pin_b3

void main()
{
set_tris_a(0b11111111);
set_tris_b(0b11110000);
output_b(0b00000000);
output_a(0b00000000);
while(true){{
if(input(pin_b4)==0)
output_low(LED);
if(input(pin_b4)==1)
output_high(LED);
if(input(pin_b4)==0)
output_low(LEA);
if(input(pin_b4)==1)
output_high(LEA);
}
{
if(input(pin_b5)==0)
output_low(LER);
if(input(pin_b5)==1)
output_high(LER);
if(input(pin_b5)==0)
output_low(LEB);
if(input(pin_b5)==1)
output_high(LEB);
}
{
if(input(pin_b6)==1)
{
output_b(0x01);
delay_ms(580);
output_b(0x00);
}
}
{
if(input(pin_b7)==1)
{
output_b(0x04);
delay_ms(580);
output_b(0x00);
}
}
}
}
LABORATORIO#2

REALIZAR UN ROBOT SEGUIDOR DE LÍNEA

SIMULACIÓN

U1
2 15
C1 RA0/AN0 RC0/T1OSO/T1CKI
3 16
RA1/AN1 RC1/T1OSI/CCP2/UOE
4 17
RA2/AN2/VREF-/CVREF RC2/CCP1/P1A
5 23
RA3/AN3/VREF+ RC4/D-/VM
22p 6 24
RA4/T0CKI/C1OUT/RCV RC5/D+/VP
X1 7
RA5/AN4/SS/LVDIN/C2OUT RC6/TX/CK
25
CRYSTAL 14 26
C3 RA6/OSC2/CLKO RC7/RX/DT/SDO
13
OSC1/CLKI
33 19
RB0/AN12/INT0/FLT0/SDI/SDA RD0/SPP0
22p 34 20
RB1/AN10/INT1/SCK/SCL RD1/SPP1
35 21
RB2/AN8/INT2/VMO RD2/SPP2
36 22
RB3/AN9/CCP2/VPO RD3/SPP3
37
38
RB4/AN11/KBI0/CSSPP RD4/SPP4
27
28
0
RB5/KBI1/PGM RD5/SPP5/P1B
39
40
RB6/KBI2/PGC RD6/SPP6/P1C
29
30
0
RB7/KBI3/PGD RD7/SPP7/P1D U2(VSS)
8
1 U2(VS)
RE0/AN5/CK1SPP
9
RE1/AN6/CK2SPP
10 out1
RE2/AN7/OESPP
18
VUSB RE3/MCLR/VPP
1
16 8 U2
PIC18F4550
2 3 out1
IN1 VSS VS OUT1
+88.8

7 6
U1(RE3/MCLR/VPP) 1
IN2 OUT2
out2 MOTOR1
EN1

9 out2
EN2
10 11 out3 out3
IN3 OUT3
15 14
IN4 GND GND OUT4 out4
+88.8

L293D
MOTOR2
out4

PROGRAMA

#include <16f877a.h>
#use delay(crystal=4 MHZ)
#fuses hs,nowdt,noprotect//reloj de 4Mhz
#byte trisa=0x85 //dirección del trisc en la memoria
#byte trisb=0x86
#byte porta=0x05
#byte portb=0x06
void main(){ //función principal
trisa=0xff;//se configura el puerto c como entrada
trisb=0x01;//se configura el puerto b como salida
portb=0b00000011;//se pone en cero el puerto b
while(true){ //se crea un buncle infinito

if((bit_test(portb,0)==0)&&(bit_test(portb,1)==0)){ //si (RB0=1 Y RA0=0 y RA1=0)


bit_clear(portb,4)&bit_set(portb,5)&bit_set(portb,6)&bit_clear(portb,7); //si se
cumple la condicion RB4=0 y RB5=0 y RB7=0 y RB6=1
}
else{

if((bit_test(portb,0)==0)&&(bit_test(portb,1)==1)){ //si (RB0=1 Y RA0=1 y RA1=0)


bit_clear(portb,4)&bit_clear(portb,5)&bit_set(portb,6)&bit_clear(portb,7); //si se
cumple la condicion RB5=0 y RB6=0 y RB7=0 y RB4=1
}
else{

if((bit_test(portb,0)==1)&&(bit_test(portb,1)==0)){ //si (RA1=1 Y RB0=1 y RA0=0)


bit_clear(portb,4)&bit_set(portb,5)&bit_clear(portb,6)&bit_clear(portb,7); //si se
cumple la condicion RB4=0 y RB6=0 y RB5=1 y RB7=1
}
else{

if((bit_test(portb,0)==1)&&(bit_test(portb,1)==1)){ //si (RA0=1 Y RA1=1 y RB0=1)


bit_clear(portb,4)&bit_clear(portb,5)&bit_clear(portb,6)&bit_clear(portb,7); //si
se cumple la condicion RB5=0 y RB6=0 y RB7=1 y RB4=1
}
else{
portb=0x00; //si no se cumple ningun IF se pone en ceroel puerto b
}
}
}
}
}
}

You might also like