Shop OBEX P1 Docs P2 Docs Learn Events
Split personality IO pin — Parallax Forums

Split personality IO pin

I've been using the smartpin repository mode in my Micropython experiments and I discovered I can use the same pin as an output too.

In this example a pin is toggled at a spped set by it's own repository value.
This feature frees up pins for more fun!
con
	vsync = 56

dat	org

	coginit	#16,#@speed

	wrpin	#%01_00001_0,#vsync	'long repository mode and OUT enabled
	dirh	#vsync			'enable smartpin

loop	rdpin	pb,#vsync		'get speed from smartpin repository
	getct	pa
	testb	pa,pb wc
	outc	#vsync
	jmp	#loop

	org
speed	waitx	##25_000_000 * 2
	wxpin	#23,#vsync			'slow speed
	waitx	##25_000_000 * 2
	wxpin	#20,#vsync			'faster speed
	jmp	#speed

Comments

Sign In or Register to comment.