Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Controlador de Fluxo para Estacionamentos
- 'com Sensores Infra-Vermelho e Semáforo
- 'Microcontrolador: ATmega328
- '---Configurações do microcontrolador---
- $regfile = "m328pdef.dat"
- $crystal = 8000000
- '---Configurações dos Pinos---
- Config Portb.0 = Output
- Config Portb.1 = Output
- Config Portb.2 = Output
- Config Portb.3 = Output
- Config Pinb.4 = Input
- Config Pinb.5 = Input
- '---Nomes dos Componentes---
- Led1_red Alias Portb.0
- Led1_green Alias Portb.1
- Led2_red Alias Portb.2
- Led2_green Alias Portb.3
- Sensor1 Alias Pinb.4
- Sensor2 Alias Pinb.5
- '---Estado Inicial dos Componentes---
- Led1_red = 0
- Led1_green = 1
- Led2_red = 0
- Led2_green = 1
- Sensor1 = 1
- Sensor2 = 1
- '---Declaração das Variáveis Globais---
- Dim Quantidade_carros_entrada As Integer
- Dim Quantidade_carros_saida As Integer
- Quantidade_carros_entrada = 0
- Quantidade_carros_saida = 0
- '---Condições de Acionamento dos Sensores---
- Do
- 'Condição Sensor1 Ativado e 0 Carros na Saída
- If Sensor1 = 0 And Quantidade_carros_saida = 0 Then
- Led2_red = 1
- Led2_green = 0
- incr Quantidade_carros_entrada
- Voltar1:
- If Sensor1 = 0 Then
- Waitms 30
- Goto Voltar1
- End If
- End If
- 'Condição Sensor2 Ativado e 0 Carros na Entrada
- If Sensor2 = 0 And Quantidade_carros_entrada = 0 Then
- Led1_red = 1
- Led1_green = 0
- Incr Quantidade_carros_saida
- Voltar2:
- If Sensor2 = 0 Then
- Waitms 30
- Goto Voltar2
- End If
- End If
- 'Condição Sensor1 Ativado e alguns Carros na Saída
- If Sensor1 = 0 And Quantidade_carros_saida > 0 Then
- Decr Quantidade_carros_saida
- Voltar3:
- If Sensor1 = 0 Then
- Waitms 30
- Goto Voltar3
- End If
- End If
- 'Condição Sensor2 Ativado e alguns Carros na Entrada
- If Sensor2 = 0 And Quantidade_carros_entrada > 0 Then
- Decr Quantidade_carros_entrada
- Voltar4:
- If Sensor2 = 0 Then
- Waitms 30
- Goto Voltar4
- End If
- End If
- 'Condição 0 Carros na Saída e na Entrada
- If Quantidade_carros_entrada = 0 And Quantidade_carros_saida = 0 Then
- Led1_green = 1
- Led2_green = 1
- Led1_red = 0
- Led2_red = 0
- End If
- Loop
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement