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

Discussion in 'Homework Help' started by Moraru Vladut, May 23, 2016.

  1. Moraru Vladut

    Thread Starter New Member

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

    [​IMG]

    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:

    Code (C):
    1.  
    2. sbit LCD_RS at RC4_bit;
    3. sbit LCD_EN at RC5_bit;
    4. sbit LCD_D4 at RC0_bit;
    5. sbit LCD_D5 at RC1_bit;
    6. sbit LCD_D6 at RC2_bit;
    7. sbit LCD_D7 at RC3_bit;
    8.  
    9. sbit LCD_RS_Direction at TRISC4_bit;
    10. sbit LCD_EN_Direction at TRISC5_bit;
    11. sbit LCD_D4_Direction at TRISC0_bit;
    12. sbit LCD_D5_Direction at TRISC1_bit;
    13. sbit LCD_D6_Direction at TRISC2_bit;
    14. sbit LCD_D7_Direction at TRISC3_bit;
    15.  
    16. // End Software I2C connections
    17.  
    18. int value;
    19. char value1[15];
    20. int value2;
    21.  
    22. void main()
    23. {
    24.      //TRISA.RA0 = 1;
    25.     // TRISA.RA1 = 1;
    26.  
    27.     // TRISD.RD7 = 1;
    28.  
    29.      PORTD = 0;
    30.      TRISD = 0;
    31.    
    32.      PORTC = 0;
    33.      TRISC = 0;
    34.  
    35.      ADC_INIT();
    36.      LCD_INIT();
    37.      lcd_cmd(_lcd_cursor_off);
    38.      lcd_cmd(_lcd_clear);
    39.      lcd_out(1,1,"Temperatura: ");
    40.  
    41.      while(1)
    42.      {
    43.              value = adc_read(0);
    44.              value = value * 0.488;
    45.              floattostr(value,value1);
    46.              lcd_chr(2,9,39);
    47.              lcd_out(2,10,"C");
    48.              lcd_out(2,1,value1);
    49.  
    50.              value2 = atoi(value1);
    51.  
    52.              if(value2 > 29)
    53.              {
    54.                PORTD.RD0 = 1;
    55.                PORTD.RD3 = 0;
    56.                PORTD.RD7 = 1;
    57.                PORTD.RD6 = 0;
    58.                PORTC.RD6 = 1;
    59.              }
    60.             else
    61.              {
    62.                PORTD.RD0 = 0;
    63.                PORTD.RD2 = 0;
    64.                PORTD.RD7 = 0;
    65.                PORTD.RD6 = 1;
    66.              }
    67.      }
    68.  
    69. }
    70.  
    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
     
  2. WBahn

    Moderator

    Mar 31, 2012
    17,768
    4,802
    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?
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,395
    497
    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.
     
  4. dannyf

    Well-Known Member

    Sep 13, 2015
    1,825
    364
    Wow!

    any way to make such a simple thing any more complicated than it already is?
     
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,395
    497
    Good training for nuclear reactor design in the future.
     
Loading...