How connecting two microcontrollers PIC16F917 and light a led at the second?

Thread Starter

Moraru Vladut

Joined May 23, 2016
1
Hi guys i need a big help, i have a problem with connecting two microcontrollers like in picture:



If my value on my thermometer is less that 30 first led light, if led is more than 30 second led light. My question is: How i get value to second microcontroller to compare and light second led?

My code is that:

C:
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;

sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;

// End Software I2C connections

int value;
char value1[15];
int value2;

void main()
{
     //TRISA.RA0 = 1;
    // TRISA.RA1 = 1;

    // TRISD.RD7 = 1;

     PORTD = 0;
     TRISD = 0;
    
     PORTC = 0;
     TRISC = 0;

     ADC_INIT();
     LCD_INIT();
     lcd_cmd(_lcd_cursor_off);
     lcd_cmd(_lcd_clear);
     lcd_out(1,1,"Temperatura: ");

     while(1)
     {
             value = adc_read(0);
             value = value * 0.488;
             floattostr(value,value1);
             lcd_chr(2,9,39);
             lcd_out(2,10,"C");
             lcd_out(2,1,value1);

             value2 = atoi(value1);

             if(value2 > 29)
             {
               PORTD.RD0 = 1;
               PORTD.RD3 = 0;
               PORTD.RD7 = 1;
               PORTD.RD6 = 0;
               PORTC.RD6 = 1;
             }
            else
             {
               PORTD.RD0 = 0;
               PORTD.RD2 = 0;
               PORTD.RD7 = 0;
               PORTD.RD6 = 1;
             }
     }

}
What i do to light second led? Or how i read a value on second microcontroller to light this, thanks a lot

Moderators note: Please use code tags for pieces of code
 

WBahn

Joined Mar 31, 2012
30,078
Why not just light both LEDs directly from a single microcontroller?

Are you trying to establish a communications link of some kind between the two MCUs? If so, what kind of link? If not, then just bring a single signal from the first MCU to the second, poll it, and copy it's value to the output to the LED.

Is there a reason that you don't have current limiting resistors on either LED?
 

shteii01

Joined Feb 19, 2010
4,644
MCU1 detects 30°C, lights LED1, sends instruction to MCU2 to start 30 second clock, sends a value to MCU2 to be stored and used in future comparison. After 30 seconds MCU2 sends a value or symbol or character to MCU1 to indicate that 30 seconds have passed, when MCU1 sees this value, it sends value corresponding to the temperature. MCU2 now has two values that correspond to the temperature, Value1 from 30 seconds ago, Value2 from right now. Compare the two values. If they the same, MCU2 lights up LED2.
 
Top