Advertisement
Guest User

Estacionamento.bas

a guest
Jun 14th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Controlador de Fluxo para Estacionamentos
  2. 'com Sensores Infra-Vermelho e Semáforo
  3. 'Microcontrolador: ATmega328
  4.  
  5. '---Configurações do microcontrolador---
  6. $regfile = "m328pdef.dat"
  7. $crystal = 8000000
  8.  
  9. '---Configurações dos Pinos---
  10. Config Portb.0 = Output
  11. Config Portb.1 = Output
  12. Config Portb.2 = Output
  13. Config Portb.3 = Output
  14. Config Pinb.4 = Input
  15. Config Pinb.5 = Input
  16.  
  17. '---Nomes dos Componentes---
  18. Led1_red Alias Portb.0
  19. Led1_green Alias Portb.1
  20. Led2_red Alias Portb.2
  21. Led2_green Alias Portb.3
  22. Sensor1 Alias Pinb.4
  23. Sensor2 Alias Pinb.5
  24.  
  25. '---Estado Inicial dos Componentes---
  26. Led1_red = 0
  27. Led1_green = 1
  28. Led2_red = 0
  29. Led2_green = 1
  30. Sensor1 = 1
  31. Sensor2 = 1
  32.  
  33. '---Declaração das Variáveis Globais---
  34. Dim Quantidade_carros_entrada As Integer
  35. Dim Quantidade_carros_saida As Integer
  36.  
  37. Quantidade_carros_entrada = 0
  38. Quantidade_carros_saida = 0
  39.  
  40. '---Condições de Acionamento dos Sensores---
  41. Do
  42.  
  43.    'Condição Sensor1 Ativado e 0 Carros na Saída
  44.    If Sensor1 = 0 And Quantidade_carros_saida = 0 Then
  45.  
  46.       Led2_red = 1
  47.       Led2_green = 0
  48.       incr Quantidade_carros_entrada
  49.  
  50.       Voltar1:
  51.       If Sensor1 = 0 Then
  52.  
  53.          Waitms 30
  54.          Goto Voltar1
  55.  
  56.       End If
  57.  
  58.    End If
  59.  
  60.    'Condição Sensor2 Ativado e 0 Carros na Entrada
  61.    If Sensor2 = 0 And Quantidade_carros_entrada = 0 Then
  62.  
  63.       Led1_red = 1
  64.       Led1_green = 0
  65.       Incr Quantidade_carros_saida
  66.  
  67.       Voltar2:
  68.       If Sensor2 = 0 Then
  69.  
  70.          Waitms 30
  71.          Goto Voltar2
  72.  
  73.       End If
  74.  
  75.    End If
  76.  
  77.    'Condição Sensor1 Ativado e alguns Carros na Saída
  78.    If Sensor1 = 0 And Quantidade_carros_saida > 0 Then
  79.  
  80.       Decr Quantidade_carros_saida
  81.  
  82.       Voltar3:
  83.       If Sensor1 = 0 Then
  84.  
  85.          Waitms 30
  86.          Goto Voltar3
  87.  
  88.       End If
  89.  
  90.    End If
  91.  
  92.    'Condição Sensor2 Ativado e alguns Carros na Entrada
  93.    If Sensor2 = 0 And Quantidade_carros_entrada > 0 Then
  94.  
  95.       Decr Quantidade_carros_entrada
  96.  
  97.       Voltar4:
  98.       If Sensor2 = 0 Then
  99.  
  100.          Waitms 30
  101.          Goto Voltar4
  102.  
  103.       End If
  104.  
  105.    End If
  106.  
  107.    'Condição 0 Carros na Saída e na Entrada
  108.    If Quantidade_carros_entrada = 0 And Quantidade_carros_saida = 0 Then
  109.  
  110.       Led1_green = 1
  111.       Led2_green = 1
  112.       Led1_red = 0
  113.       Led2_red = 0
  114.  
  115.    End If
  116.  
  117. Loop
  118.  
  119. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement