Yup, or there's no pull-up/down resistor. whatever
Code:'------------------------------------------------------------------------------------------- ' ' The following have been tested, no problem at all ' ' Hardware description ' 1) LEDs connected betwee PIC I/O and GND via resistor ' 2) Push button between PIC and GND... nothing else. ' '------------------------------------------------------------------------------------------- @ __config _WDT_OFF & _MCLRE_OFF & _CP_OFF ' Disable watch dog timer ' Disable MLCR, GP3 as I/O ' Disable Code Protection Red var GPIO.0 Green var GPIO.1 Blue var GPIO.2 SwitchPin var GPIO.3 ' Active low OPTION_REG = %00000000 ' -0-------- _GPWU -- Disable Wake-Up on pin change ' --0------- _GFPPU - Enable Weak Pull-Ups ' ---0------ T0CS --- Timer0 Clock Source Internal (O T0CKI pin, 0 Internal) ' ----xxxxx- Timer0 related stuff... don't care TRISIO = 0 ' Clear all I/Os GPIO = %00001000 ' GP3: Input, other pin: Output ButtonCount VAR BYTE MAIN: IF !SwitchPin THEN ' Switch down? ' - YES If ButtonCount = 3 THEN ButtonCount = 0 ' - Currently on GP3 (MCLR)? If so, pass go, claim 200$ pwm ButtonCount,127,100 ' - Light Show WHILE !SwitchPin : wend ' - Spin 'till button is released pAUSE 50 ' - arbitrary debouince delay ButtonCount = ButtonCount + 1 ' - Point to next LED endif ' GOTO MAIN





Bookmarks