Advertisement
kevin2458

Kevin Lara - 201110510072 - Microcontroladores - 25/06/2016

Jun 25th, 2016
2,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program linefollower                                                        
  2.                                                                            
  3. ' Declarations section                                                      
  4. symbol imput1 =portb.2                                                      
  5. symbol imput2 =porta.2                                                      
  6. symbol imput3 =portc.6                                                      
  7. symbol imput4 =portd.5                                                      
  8. symbol imput5 =portd.6                                                      
  9.                                                                            
  10. symbol push1 =portd.3                                                      
  11. symbol push2 =portd.2                                                      
  12. symbol led1 =lata.0                                                        
  13. symbol led2 =lata.1                                                        
  14.                                                                            
  15. dim line_follow as byte                                                    
  16.                                                                            
  17.                                                                            
  18.                                                                            
  19. sub procedure init_MCU()                                                    
  20.      adcon0 = %00000000     ' apagamos los canales analogicos              
  21.      adcon1 = %00000000                                                    
  22.  'configuracion de pines correspondientes al line follower'                
  23. portb.2 = 1                                                                
  24. porta.2 = 1                                                                
  25. portc.6 = 1                                                                
  26. portd.5 = 1                                                                
  27. portd.6 = 1                                                                
  28.   'Configuracion pic cliker led y pulsadores'                              
  29. trisd.3 =1                                                                  
  30. trisd.2 =1                                                                  
  31. trisa.0 =0                                                                  
  32. trisa.1 =0                                                                  
  33.                                                                            
  34.       'limpiamos los registros lat y port para evitar datos residuales'    
  35.      lata = 0                                                              
  36.      latd = 0                                                              
  37.      latc = 0                                                              
  38.      latb = 0                                                              
  39.                                                                            
  40.      porta =0                                                              
  41.      portd =0                                                              
  42.      portc =0                                                              
  43.      portb =0                                                              
  44. end sub                                                                    
  45.                                                                            
  46.                                                                            
  47. sub procedure lec_follow_click()                                            
  48.     line_follow.0 = imput5                                                  
  49.     line_follow.1 = imput4                                                  
  50.     line_follow.2 = imput3                                                  
  51.     line_follow.3 = imput2                                                  
  52.     line_follow.4 = imput1                                                  
  53.     line_follow.5 = 0                                                      
  54.     line_follow.6 = 0                                                      
  55.     line_follow.7 = 0                                                      
  56.        'si ninguno = 255'                                                  
  57. end sub                                                                    
  58.                                                                            
  59. main:
  60. init_MCU()                                                                        
  61. '   Main program                                                            
  62. while true                                                                  
  63.  lec_follow_click()                                                          
  64. select case line_follow                                                    
  65. case 31                                                                    
  66. led1=1                                                                      
  67. led2=1                                                                      
  68.                                                                            
  69. case 1                                                                      
  70. led2= not led2                                                              
  71. delay_ms(200)                                                              
  72.                                                                            
  73. case 3                                                                      
  74. led2= not led2                                                              
  75. delay_ms(100)                                                              
  76.                                                                            
  77. case 6                                                                      
  78. led2= not led2                                                              
  79. led1 = not led1                                                            
  80. delay_ms(100)                                                              
  81.                                                                            
  82. case 12                                                                    
  83. led2= not led2                                                              
  84. led1 = not led1                                                            
  85. delay_ms(100)                                                              
  86.                                                                            
  87. case 24                                                                    
  88. led1 = not led1                                                            
  89. delay_ms(100)                                                              
  90.                                                                            
  91. case 16                                                                    
  92. led1 = not led1                                                            
  93. delay_ms(200)                                                              
  94.                                                                            
  95.                                                                            
  96.                                                                            
  97.                                                                            
  98.  end select                                                                            
  99. wend                                                                        
  100.                                                                
  101. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement