Question
Can anyone write the code below by using PIC18F45K80 please This is the code using pic16F877A: // LCD module connections sbit LCD_RS at RD0_bit; sbit
Can anyone write the code below by using PIC18F45K80 please
This is the code using pic16F877A:
// LCD module connections
sbit LCD_RS at RD0_bit;
sbit LCD_EN at RD1_bit;
sbit LCD_D4 at RD2_bit;
sbit LCD_D5 at RD3_bit;
sbit LCD_D6 at RD4_bit;
sbit LCD_D7 at RD5_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD2_bit;
sbit LCD_D5_Direction at TRISD3_bit;
sbit LCD_D6_Direction at TRISD4_bit;
sbit LCD_D7_Direction at TRISD5_bit;
unsigned int analog_in;
float light;
char text[ ] = "00.00";
unsigned char duty;
void main() {
int temp=0;
ADC_Init();
LCD_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
TRISA = 0x04;
TRISC = 0;
PORTC=0;
TRISB= 0;
TRISD=0;
PORTB=0;
while(1){
Lcd_Cmd(_LCD_CLEAR);
analog_in = ADC_Read(2);
light = (float)analog_in* 500.0 / 1023.0;
FloatToStr_FixLen(light,text,5);
Lcd_Out (1,1,"light");
Lcd_Out_Cp(text);
if (light>400 && temp==0) {
PORTB.B0=1;
PORTB.B1=0;
PORTB.B4=1;
PORTB.B5=0;
Lcd_out(2,1,"w. Open");
delay_ms(1000);
PORTB=0;
temp=1;
}
if(light
PORTB.B0=0;
PORTB.B1=1;
PORTB.B4=0;
PORTB.B5=1;
Lcd_Out(2,1,"w closed");
delay_ms(5000);
PORTB=0;
temp=0;
}
this is circuit simulation:
Can anyone write the code using PIC18F45K80 please
PIC18F45K80 SHOWN BELOW:
B1 12V 4 19 U2 4 5 C1 vec VS OUT 2 12 +3 IN1 INC INS IN4 ENA . 1EPF Hoh OUT2 3 OUT 13 OUT4 14 X2 CRYSTAL 3 15 SENSA SENSE GND D2 C2 8 LE R2 BD.CREEN 15-F HOME TIT 220 R1 LED RED A -- 220 RV1 U1 13 OSCULKIN 33 14 REMINT OSC2 CLKOUT RB1 3.4 35 REZ RBON RABAND Se 3 SE RATAN RB4 4 RAZIANA VREF./CVREF RES 38 RABAN/VREF+ RPGC 39 40 R14/TDR C10u| 7 RBTIPOD RAGANASSICZOUT 8 RDOTIOSOITICKI RELANIRD RC1/T108 CCP2 RELIANEWR 17 10 RC2/CCP REZANTICE RCI SCRISOL FCASDSDA MCLRIVA/THV RCS SDO RCE TXICK RCTIXDT 26 19 RDOPSFO 20 RD1/PSP: ROOPSP2 RDS PSP3 27 RDA PSP 28 RDS PSPS RDGFSFE 29 30 RDTPSPY PC16F877A 1 :01 R3 10k 988283886 olellele LCD1 LMOTEL 10 -0 D 820 LDR1 LOR Pin-outs 2 Von AWN 5 7 8 MCLR/PP/RE3 RA0/AN/CVREF RA1/AN1 RA2/AN2/REF- RA3/AN3/VREF+ RA4/TOCKI RA5/AN4/SS/HLVDIN REO/RD/AN5 RE1/WR/AN6/C1OUT RE2/CSIAN7/C2OUT VDD Vss OSC1/CLKI/RA7 OSC2/CLKO/RA6 RCO/T10SO/T13CKI RC1/T1OSI RC2/CCP1 RC3/SCKISCL RDO/PSPO/C1IN+ RD 1/PSP1/C1IN- PIC18F4480 PIC18F4580 9 10 11 12 13 14 15 16 - 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22. 21 RB7/KB/3/PGD RB6/KBI2/PGC RB5/KBI1/PGM RB4/KBIO/ANG RB3/CANRX RB2/INT2/CANTX RB1/INT1/ANS RBO/INTO/FLTO/AN10 VDD Vss RD7/PSP7/P1D RD6/PSP6/P1C RD5/PSP5/P1B RD4/PSP4/ECCP1/P1A RC7/RX/DT RC6/TXICK RC5/SDO RC4/SDI/SDA RD3/PSP3/C2IN- RD2/PSP2/C2IN+ 2 g 0 0 3 0 9 8
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started