'**************************************************************** '* Name : LAB_Benchverlichting.bas * '* Author : Marcel Alkema * '* Notice : Copyright (c) 2024 Marcel Alkema * '* : All Rights Reserved * '* Date : 07-02-2024 * '* Version : 1 .0 * '* Notes : Uitprint datum 25-10-2024 * '* : Gr1+2+3 al werkend zonder S1/2/3 en LEDs * '**************************************************************** Device 16F628A ;Gebruik een 16F628A type Config INTRC_OSC_NOCLKOUT,_ WDT_OFF,_ PWRTE_ON,_ LVP_OFF,_ MCLRE_OFF All_Digital TRUE ;Alle ingangen digitaal Xtal =4 Symbol LEDIO = PORTA.2 ; PORTA.2 heet nu LEDIO (ON/OFF) Symbol LED1 = PORTA.0 ; PORTA.0 heet nu LED1 (Groep 1) Symbol LED2 = PORTA.1 ; PORTA.1 heet nu LED2 (Groep 2) Symbol LED3 = PORTA.6 ; PORTA.6 heet nu LED3 (Groep 3) Symbol LED4 = PORTA.7 ; PORTA.7 heet nu LED4 (Groep 4) Symbol LED5 = PORTB.0 ; PORTB.0 heet nu LED5 (Fade in indicatie) Symbol LED6 = PORTB.1 ; PORTB.1 heet nu LED6 (Fade out indicatie) Symbol sw1 = PORTA.3 ; PORTA.3 heet nu SW1 (Enter) Symbol sw2 = PORTA.4 ; PORTA.4 heet nu SW2 (Down) Symbol sw3 = PORTA.5 ; PORTA.5 heet nu SW3 (Up) Dim TELLER As Byte Dim tel_BIT As Bit Dim DUTY As Byte Dim DUTY_1 As Byte PORTA = %00000000 ;Alle niveaus van PORTA laag PORTB = %00000000 ;Alle niveaus van PORTB laag Clear Low LED1 Low LED2 Low LED3 Low LED4 High LEDIO DelayMS 500 Cls While 1 = 1 Low LED4 Low LED5 Low LED6 DelayMS 1000 High LED1 DelayMS 1000 High LED2 DelayMS 1000 High LED3 TELLER = 1 Print At 1,1,"MENU KEUS = ", Dec2 TELLER RUN: If TELLER = 1 Then Print At 2,1, "LICHTGROEP 1 AAN" If TELLER = 2 Then Print At 2,1, "LICHTGROEP 1 UIT" If TELLER = 3 Then Print At 2,1, "LICHTGROEP 2 AAN" If TELLER = 4 Then Print At 2,1, "LICHTGROEP 2 UIT" If TELLER = 5 Then Print At 2,1, "LICHTGROEP 3 AAN" If TELLER = 6 Then Print At 2,1, "LICHTGROEP 3 UIT" If TELLER = 7 Then Print At 2,1, "LICHTGR. 123 AAN" If TELLER = 8 Then Print At 2,1, "LICHTGR. 123 UIT" If TELLER = 9 Then Print At 2,1, "LICHTGROEP 4 AAN" If TELLER = 10 Then Print At 2,1, "LICHTGROEP 4 UIT" If TELLER = 11 Then Print At 2,1, "GROEP 4 FADE IN " If TELLER = 12 Then Print At 2,1, "GROEP 4 FADE UIT" If TELLER = 1 And sw1= 1 Then High LED1 End If If TELLER = 2 And sw1= 1 Then Low LED1 End If If TELLER = 3 And sw1= 1 Then High LED2 End If If TELLER = 4 And sw1= 1 Then Low LED2 End If If TELLER = 5 And sw1= 1 Then High LED3 End If If TELLER = 6 And sw1= 1 Then Low LED3 End If If TELLER = 7 And sw1= 1 Then High LED1 High LED2 High LED3 End If If TELLER = 8 And sw1= 1 Then Low LED1 Low LED2 Low LED3 End If If TELLER = 9 And sw1= 1 Then Low LED1 Low LED2 Low LED3 High LED4 End If If TELLER = 10 And sw1= 1 Then Low LED1 Low LED2 Low LED3 Low LED4 End If If TELLER = 11 And sw1= 1 Then Low LED1 Low LED2 Low LED3 For DUTY = 1 To 254 ; Fade in PWM PORTA.7, DUTY, 100 Toggle LED5 Next High LED4 Low LED5 End If If TELLER = 12 And sw1= 1 Then Low LED1 Low LED2 Low LED3 Low LED5 For DUTY = 1 To 254 ; FADE out PWM PORTA.7, 255-DUTY, 100 Toggle LED6 Next Low LED6 End If If sw3 = 1 Then tel_BIT = 1 GoSub TEL_PLUS_1 EndIf If sw2 = 1 Then tel_BIT = 1 GoSub TEL_AF EndIf GoTo RUN TEL_PLUS_1: If tel_BIT = 1 Then TELLER = TELLER + 1 EndIf Print At 1,1,"MENU KEUS = ",Dec2 TELLER tel_BIT = 0 If TELLER > 12 Then TELLER = TELLER - 1 EndIf If sw3 = 0 Then If tel_BIT = 0 Then Return EndIf EndIf GoTo TEL_PLUS_1 TEL_AF: If tel_BIT = 1 Then TELLER = TELLER - 1 EndIf Print At 1,1,"MENU KEUS = ",Dec2 TELLER tel_BIT = 0 If TELLER = 0 Then TELLER = TELLER + 1 EndIf If sw2 = 0 Then If tel_BIT = 0 Then Return EndIf EndIf GoTo TEL_AF Wend End