'---------------Title--------------

' File......master_slave_slave1.pbp
' Started....11/17/07
' Microcontroller used:  Microchip Technology 16F88
'                        microchip.com
' PBPro Code, micro-Engineering Labs, Inc.
'             melabs.com 
 
'--------Program Desciption--------

' Receives timing signal from the master 
' microcontroller (MCU) which triggers this slave MCU 
' to start its program.

'----------Related Lesson----------

' master_slave_slave1.pbp is used in the
' lesson PIC PROGRAMMING 3 SERVOS at:
' http://cornerstonerobotics.org/curriculum/lessons_year2/erii13_pic_programming3_servos.pdf
    
'------------Variables-------------

     c0		     VAR		BYTE	  ' Byte for counter   
     led         var        PORTB.0   ' Labels PORTB.0 as led 
     masterin    var        PORTB.1   ' Labels PORTB.1 as master input
	
'----------Initialization----------

    TRISB = %11111110           ' Sets PORTB.0 as output,
                                ' PORTB.1 - PORTB.7 as inputs
    
    PORTB = %00000000           ' Sets all PORTB pins at LOW

    OSCCON = $60	            ' Sets the internal oscillator in the
                                ' 16F88 to 4 MHz   	                

'-------------Main Code------------

loop:

    If masterin = 1 then blink  ' If the input pin masterin (PORTB.1)
                                ' receives a HIGH signal from the 
                                ' master MCU, then this program will
                                ' jump to blink label.  If the input
                                ' pin remains LOW, this program
                                ' will continue to loop, monitoring
                                ' the masterin pin.          
    
    goto loop                   ' Loop to loop label
    
blink:                          ' blink label
    
    High led                    ' Sets led (PORTB.0) to HIGH
    
    Pause 500                   ' Pause 500 ms
    
    low led                     ' Sets led (PORTB.0) to LOW
    
    pause  500                  ' Pause 500 ms
    
    goto loop                   ' Loop to loop label
    
    end	  	  	
                            

