HOUDAGHO
Newbie
Hello to all, I would like to carry out a project whose principle is the following:
we have two PIC 16F88 microcontrollers, the first peak is the master allows to read the temperature on an LM35 sensor and send it to the other peak which is the slave and the latter which allows to send the sun temperature an LCD.
I tried several times, but no solution succeeded
master :
slave
[moderator action: added code tags]
we have two PIC 16F88 microcontrollers, the first peak is the master allows to read the temperature on an LM35 sensor and send it to the other peak which is the slave and the latter which allows to send the sun temperature an LCD.
I tried several times, but no solution succeeded
master :
Code:
sbit swcw at PORTB.b0;
sbit swcw_direction at TRISB.b0;
sbit swccw at PORTA.b0;
sbit swccw_direction at TRISA.b0;
//outputs
sbit sck at PORTB.b3;
sbit sck_direction at TRISB.b3;
//outputs
sbit dt at PORTB.b5;
sbit dt_direction at TRISB.b5;
//constants
const char motorcw=0x01;
const char motorccw=0x02;
const char motoridle=0x03;
unsigned int a;
char temp[7];
void main() {
TRISB = 0x00; PORTB = 0x00;
ADC_Init();
//initialization
ANSEL=0x00;
swccw=0;
swcw_direction=1;
swccw=0;
swccw_direction=1;
//Configure MSSP 3 registers
SSPSTAT.SMP=1;
SSPSTAT.CKE=0;
SSPCON.WCOL=0;
SSPCON.SSPOV=0;
SSPCON.SSPM3=0;
SSPCON.SSPM2=0;
SSPCON.SSPM1=0;
SSPCON.SSPM0=0;
SSPCON.SSPEN=1;
sck=0;
sck_direction=0;
dt=0;
dt_direction=0;
TRISB.RB4=0;
Delay_ms(50);
while(1); {
a = ADC_Read(0);
a = a*5/1023;
inttostr(a,temp);
}
}
slave
Code:
sbit sck at PORTB.b3;
sbit sck_direction at TRISB.b4;
sbit dt at PORTB.b4;
sbit dt_direction at TRISB.b4;
//outputs
sbit mcw at PORTB.b5;
sbit mcw_direction at TRISB.b5;
sbit mccw at PORTB.b7;
sbit mccw_direction at TRISB.b7;
//variables
char rcdata;
//constants
const char motorcw=0x01;
const char motorccw=0x02;
const char motoridle=0x03;
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
void main() {
lcd_init ();
lcd_cmd(_lcd_cursor_off);
//initialization
ANSEL=0x00;
//Configure MSSP 3 registers
SSPSTAT.SMP=1;
SSPSTAT.CKE=0;
SSPCON.WCOL=0;
SSPCON.SSPOV=0;
SSPCON.SSPM3=0;
SSPCON.SSPM2=1;
SSPCON.SSPM1=0;
SSPCON.SSPM0=1;
SSPCON.SSPEN=1;
sck=0;
sck_direction=1;
dt=0;
dt_direction=1;
mcw=0;
mcw_direction=0;
mccw=0;
mccw_direction=0;
Delay_ms(50);
while (1){
lcd_out(1,1,"khadija");
lcd_out(2,1,"Houda & zohra");
delay_ms(500);
lcd_cmd(_lcd_clear);
delay_ms(500);
rcdata=SSPBUF;
switch (rcdata){
case motorcw:
mcw=1;
mccw=0;
break;
case motorccw:
mcw=0;
mccw=1;
break;
case motoridle:
mcw=0;
mccw=0;
break;
}
}
}
Last edited by a moderator: