Code:'simple 4 channel DMX controller 'reads 4 potmeters to control 4 lights '08-02-08 Kees Reedijk @ DEVICE PIC16F88, MCLR_OFF, HS_OSC, WDT_ON, LVP_OFF, PWRT_ON DEFINE OSC 20 ' 20MHZ crystal DEFINE ADC_BITS 8 ' Set number of bits DEFINE ADC_CLOCK 3 ' Set clock source DEFINE ADC_SAMPLEUS 50 ' Set sampling time DEFINE HSER_SPBRG 4 ' 250 KBaud DEFINE HSER_CLROERR 1 ' Clear overflow automatically RCSTA=%01010000 '9 bit data,usart disabled TXSTA=%01100101 'Enable transmit, BRGH=1, 9 bit data PORTA= %00000000 TRISA= %00001111 PORTB= %00100000 TRISB= %00000100 ANSEL= %00001111 CMCON= %00000111 DMX VAR PORTB.5 'DMX output to SN75176 bus driver level1 VAR BYTE level2 VAR BYTE level3 VAR BYTE level4 VAR BYTE CLEAR loop: ADCIN 0,level1 'read level potmeters ADCIN 1,level2 ADCIN 2,level3 ADCIN 3,level4 LOW DMX PAUSEUS 100 HIGH DMX PAUSEUS 12 RCSTA.7=1 'usart enabled HSEROUT [0,level1,level2,level3,level4] PAUSE 10 RCSTA.7=0 'usart disabled GOTO loop END
Bookmarks