今天做了一個四合一七段顯示器的demo程式,還蠻有趣的(請注意:我使用的七段顯示器為共陽極,如果你手上的是共陰極,程式碼則須做對應的修改)。沒想到這個東西還可以當成廣告看板來玩,有興趣的朋友歡迎用我的程式來改成你要的顯示效果。完整程式碼列在最後。
硬體接線方式很簡單,直接將四合一七段顯示器的1~12腳,依序接到arduino uno上的 pin2~pin13,就這樣而已。
https://www.youtube.com/watch?v=z0JtO_cvwCA&feature=youtu.be
以下為完整程式:
#define TEST_SEQ_LEN 591
const unsigned char PROGMEM test_seq[TEST_SEQ_LEN][5] = {
/* 1 bar circle around: 36 */
{0xfe, 0xff, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xf7, 10},
{0xff, 0xff, 0xf7, 0xff, 10},
{0xff, 0xf7, 0xff, 0xff, 10},
{0xf7, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xf7, 10},
{0xff, 0xff, 0xf7, 0xff, 10},
{0xff, 0xf7, 0xff, 0xff, 10},
{0xf7, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xf7, 10},
{0xff, 0xff, 0xf7, 0xff, 10},
{0xff, 0xf7, 0xff, 0xff, 10},
{0xf7, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
/* circle all 4 seg.: 36 */
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xfe, 10},
{0xfe, 0xfe, 0xfe, 0xfc, 10},
{0xfe, 0xfe, 0xfe, 0xf8, 10},
{0xfe, 0xfe, 0xfe, 0xf0, 10},
{0xfe, 0xfe, 0xf6, 0xf0, 10},
{0xfe, 0xf6, 0xf6, 0xf0, 10},
{0xf6, 0xf6, 0xf6, 0xf0, 10},
{0xe6, 0xf6, 0xf6, 0xf0, 10},
{0xc6, 0xf6, 0xf6, 0xf0, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xfe, 10},
{0xfe, 0xfe, 0xfe, 0xfc, 10},
{0xfe, 0xfe, 0xfe, 0xf8, 10},
{0xfe, 0xfe, 0xfe, 0xf0, 10},
{0xfe, 0xfe, 0xf6, 0xf0, 10},
{0xfe, 0xf6, 0xf6, 0xf0, 10},
{0xf6, 0xf6, 0xf6, 0xf0, 10},
{0xe6, 0xf6, 0xf6, 0xf0, 10},
{0xc6, 0xf6, 0xf6, 0xf0, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xff, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xff, 10},
{0xfe, 0xfe, 0xfe, 0xfe, 10},
{0xfe, 0xfe, 0xfe, 0xfc, 10},
{0xfe, 0xfe, 0xfe, 0xf8, 10},
{0xfe, 0xfe, 0xfe, 0xf0, 10},
{0xfe, 0xfe, 0xf6, 0xf0, 10},
{0xfe, 0xf6, 0xf6, 0xf0, 10},
{0xf6, 0xf6, 0xf6, 0xf0, 10},
{0xe6, 0xf6, 0xf6, 0xf0, 10},
{0xc6, 0xf6, 0xf6, 0xf0, 10},
/* h snake: 48 */
{0xdf, 0xff, 0xff, 0xff, 10},
{0xde, 0xff, 0xff, 0xff, 10},
{0xde, 0xfe, 0xff, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xfe, 10},
{0xde, 0xfe, 0xfe, 0xfc, 10},
{0xde, 0xfe, 0xfe, 0xbc, 10},
{0xde, 0xfe, 0xbe, 0xbc, 10},
{0xde, 0xbe, 0xbe, 0xbc, 10},
{0x9e, 0xbe, 0xbe, 0xbc, 10},
{0x8e, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xb4, 10},
{0x86, 0xb6, 0xb6, 0xb0, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xde, 0xff, 0xff, 0xff, 10},
{0xde, 0xfe, 0xff, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xfe, 10},
{0xde, 0xfe, 0xfe, 0xfc, 10},
{0xde, 0xfe, 0xfe, 0xbc, 10},
{0xde, 0xfe, 0xbe, 0xbc, 10},
{0xde, 0xbe, 0xbe, 0xbc, 10},
{0x9e, 0xbe, 0xbe, 0xbc, 10},
{0x8e, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xb4, 10},
{0x86, 0xb6, 0xb6, 0xb0, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xde, 0xff, 0xff, 0xff, 10},
{0xde, 0xfe, 0xff, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xff, 10},
{0xde, 0xfe, 0xfe, 0xfe, 10},
{0xde, 0xfe, 0xfe, 0xfc, 10},
{0xde, 0xfe, 0xfe, 0xbc, 10},
{0xde, 0xfe, 0xbe, 0xbc, 10},
{0xde, 0xbe, 0xbe, 0xbc, 10},
{0x9e, 0xbe, 0xbe, 0xbc, 10},
{0x8e, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xbe, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xbe, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xbc, 10},
{0x86, 0xb6, 0xb6, 0xb4, 10},
{0x86, 0xb6, 0xb6, 0xb0, 10},
/* 1 bar snake : 72 */
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfd, 0xff, 0xff, 0xff, 10},
{0xfb, 0xff, 0xff, 0xff, 10},
{0x7f, 0xff, 0xff, 0xff, 10},
{0xff, 0xef, 0xff, 0xff, 10},
{0xff, 0xdf, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xfd, 0xff, 0xff, 10},
{0xff, 0xfb, 0xff, 0xff, 10},
{0xff, 0x7f, 0xff, 0xff, 10},
{0xff, 0xff, 0xef, 0xff, 10},
{0xff, 0xff, 0xdf, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xfd, 0xff, 10},
{0xff, 0xff, 0xfb, 0xff, 10},
{0xff, 0xff, 0x7f, 0xff, 10},
{0xff, 0xff, 0xff, 0xef, 10},
{0xff, 0xff, 0xff, 0xdf, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0x7f, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfd, 0xff, 0xff, 0xff, 10},
{0xfb, 0xff, 0xff, 0xff, 10},
{0x7f, 0xff, 0xff, 0xff, 10},
{0xff, 0xef, 0xff, 0xff, 10},
{0xff, 0xdf, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xfd, 0xff, 0xff, 10},
{0xff, 0xfb, 0xff, 0xff, 10},
{0xff, 0x7f, 0xff, 0xff, 10},
{0xff, 0xff, 0xef, 0xff, 10},
{0xff, 0xff, 0xdf, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xfd, 0xff, 10},
{0xff, 0xff, 0xfb, 0xff, 10},
{0xff, 0xff, 0x7f, 0xff, 10},
{0xff, 0xff, 0xff, 0xef, 10},
{0xff, 0xff, 0xff, 0xdf, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0x7f, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xff, 10},
{0xfe, 0xff, 0xff, 0xff, 10},
{0xfd, 0xff, 0xff, 0xff, 10},
{0xfb, 0xff, 0xff, 0xff, 10},
{0x7f, 0xff, 0xff, 0xff, 10},
{0xff, 0xef, 0xff, 0xff, 10},
{0xff, 0xdf, 0xff, 0xff, 10},
{0xff, 0xfe, 0xff, 0xff, 10},
{0xff, 0xfd, 0xff, 0xff, 10},
{0xff, 0xfb, 0xff, 0xff, 10},
{0xff, 0x7f, 0xff, 0xff, 10},
{0xff, 0xff, 0xef, 0xff, 10},
{0xff, 0xff, 0xdf, 0xff, 10},
{0xff, 0xff, 0xfe, 0xff, 10},
{0xff, 0xff, 0xfd, 0xff, 10},
{0xff, 0xff, 0xfb, 0xff, 10},
{0xff, 0xff, 0x7f, 0xff, 10},
{0xff, 0xff, 0xff, 0xef, 10},
{0xff, 0xff, 0xff, 0xdf, 10},
{0xff, 0xff, 0xff, 0xfe, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0x7f, 10},
/*v snake: 60*/
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xf1, 10},
{0xff, 0xff, 0xff, 0xe1, 10},
{0xff, 0xff, 0xff, 0xc1, 10},
{0xff, 0xff, 0xfd, 0xc1, 10},
{0xff, 0xff, 0xf9, 0xc1, 10},
{0xff, 0xff, 0xf1, 0xc1, 10},
{0xff, 0xff, 0xe1, 0xc1, 10},
{0xff, 0xff, 0xc1, 0xc1, 10},
{0xff, 0xfd, 0xc1, 0xc1, 10},
{0xff, 0xf9, 0xc1, 0xc1, 10},
{0xff, 0xf1, 0xc1, 0xc1, 10},
{0xff, 0xe1, 0xc1, 0xc1, 10},
{0xff, 0xc1, 0xc1, 0xc1, 10},
{0xfd, 0xc1, 0xc1, 0xc1, 10},
{0xf9, 0xc1, 0xc1, 0xc1, 10},
{0xf1, 0xc1, 0xc1, 0xc1, 10},
{0xe1, 0xc1, 0xc1, 0xc1, 10},
{0xc1, 0xc1, 0xc1, 0xc1, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xf1, 10},
{0xff, 0xff, 0xff, 0xe1, 10},
{0xff, 0xff, 0xff, 0xc1, 10},
{0xff, 0xff, 0xfd, 0xc1, 10},
{0xff, 0xff, 0xf9, 0xc1, 10},
{0xff, 0xff, 0xf1, 0xc1, 10},
{0xff, 0xff, 0xe1, 0xc1, 10},
{0xff, 0xff, 0xc1, 0xc1, 10},
{0xff, 0xfd, 0xc1, 0xc1, 10},
{0xff, 0xf9, 0xc1, 0xc1, 10},
{0xff, 0xf1, 0xc1, 0xc1, 10},
{0xff, 0xe1, 0xc1, 0xc1, 10},
{0xff, 0xc1, 0xc1, 0xc1, 10},
{0xfd, 0xc1, 0xc1, 0xc1, 10},
{0xf9, 0xc1, 0xc1, 0xc1, 10},
{0xf1, 0xc1, 0xc1, 0xc1, 10},
{0xe1, 0xc1, 0xc1, 0xc1, 10},
{0xc1, 0xc1, 0xc1, 0xc1, 10},
{0xff, 0xff, 0xff, 0xfd, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xf1, 10},
{0xff, 0xff, 0xff, 0xe1, 10},
{0xff, 0xff, 0xff, 0xc1, 10},
{0xff, 0xff, 0xfd, 0xc1, 10},
{0xff, 0xff, 0xf9, 0xc1, 10},
{0xff, 0xff, 0xf1, 0xc1, 10},
{0xff, 0xff, 0xe1, 0xc1, 10},
{0xff, 0xff, 0xc1, 0xc1, 10},
{0xff, 0xfd, 0xc1, 0xc1, 10},
{0xff, 0xf9, 0xc1, 0xc1, 10},
{0xff, 0xf1, 0xc1, 0xc1, 10},
{0xff, 0xe1, 0xc1, 0xc1, 10},
{0xff, 0xc1, 0xc1, 0xc1, 10},
{0xfd, 0xc1, 0xc1, 0xc1, 10},
{0xf9, 0xc1, 0xc1, 0xc1, 10},
{0xf1, 0xc1, 0xc1, 0xc1, 10},
{0xe1, 0xc1, 0xc1, 0xc1, 10},
{0xc1, 0xc1, 0xc1, 0xc1, 10},
/* 4 bar snake : 75*/
{0xff, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xcf, 0xff, 0xff, 0xff, 10},
{0xce, 0xff, 0xff, 0xff, 10},
{0xcc, 0xff, 0xff, 0xff, 10},
{0xd8, 0xff, 0xff, 0xff, 10},
{0xf8, 0xef, 0xff, 0xff, 10},
{0xf9, 0xcf, 0xff, 0xff, 10},
{0xfb, 0xce, 0xff, 0xff, 10},
{0xff, 0xcc, 0xff, 0xff, 10},
{0xff, 0xd8, 0xff, 0xff, 10},
{0xff, 0xf8, 0xef, 0xff, 10},
{0xff, 0xf9, 0xcf, 0xff, 10},
{0xff, 0xfb, 0xce, 0xff, 10},
{0xff, 0xff, 0xcc, 0xff, 10},
{0xff, 0xff, 0xd8, 0xff, 10},
{0xff, 0xff, 0xf8, 0xef, 10},
{0xff, 0xff, 0xf9, 0xcf, 10},
{0xff, 0xff, 0xfb, 0xce, 10},
{0xff, 0xff, 0xff, 0xcc, 10},
{0xff, 0xff, 0xff, 0xd8, 10},
{0xff, 0xff, 0xff, 0xf8, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xcf, 0xff, 0xff, 0xff, 10},
{0xce, 0xff, 0xff, 0xff, 10},
{0xcc, 0xff, 0xff, 0xff, 10},
{0xd8, 0xff, 0xff, 0xff, 10},
{0xf8, 0xef, 0xff, 0xff, 10},
{0xf9, 0xcf, 0xff, 0xff, 10},
{0xfb, 0xce, 0xff, 0xff, 10},
{0xff, 0xcc, 0xff, 0xff, 10},
{0xff, 0xd8, 0xff, 0xff, 10},
{0xff, 0xf8, 0xef, 0xff, 10},
{0xff, 0xf9, 0xcf, 0xff, 10},
{0xff, 0xfb, 0xce, 0xff, 10},
{0xff, 0xff, 0xcc, 0xff, 10},
{0xff, 0xff, 0xd8, 0xff, 10},
{0xff, 0xff, 0xf8, 0xef, 10},
{0xff, 0xff, 0xf9, 0xcf, 10},
{0xff, 0xff, 0xfb, 0xce, 10},
{0xff, 0xff, 0xff, 0xcc, 10},
{0xff, 0xff, 0xff, 0xd8, 10},
{0xff, 0xff, 0xff, 0xf8, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xef, 0xff, 0xff, 0xff, 10},
{0xcf, 0xff, 0xff, 0xff, 10},
{0xce, 0xff, 0xff, 0xff, 10},
{0xcc, 0xff, 0xff, 0xff, 10},
{0xd8, 0xff, 0xff, 0xff, 10},
{0xf8, 0xef, 0xff, 0xff, 10},
{0xf9, 0xcf, 0xff, 0xff, 10},
{0xfb, 0xce, 0xff, 0xff, 10},
{0xff, 0xcc, 0xff, 0xff, 10},
{0xff, 0xd8, 0xff, 0xff, 10},
{0xff, 0xf8, 0xef, 0xff, 10},
{0xff, 0xf9, 0xcf, 0xff, 10},
{0xff, 0xfb, 0xce, 0xff, 10},
{0xff, 0xff, 0xcc, 0xff, 10},
{0xff, 0xff, 0xd8, 0xff, 10},
{0xff, 0xff, 0xf8, 0xef, 10},
{0xff, 0xff, 0xf9, 0xcf, 10},
{0xff, 0xff, 0xfb, 0xce, 10},
{0xff, 0xff, 0xff, 0xcc, 10},
{0xff, 0xff, 0xff, 0xd8, 10},
{0xff, 0xff, 0xff, 0xf8, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
/* h spand :54 */
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xf9, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xc9, 0xc9, 0xc9, 10},
{0xff, 0xf9, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xc9, 0xc9, 10},
{0xff, 0xff, 0xf9, 0xc9, 10},
{0xff, 0xff, 0xff, 0xc9, 10},
{0xff, 0xff, 0xff, 0xf9, 10},
{0xff, 0xff, 0xff, 0xff, 10},
/* 2 way h spand: 54*/
{0xff, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xff, 0xff, 0xff, 0xff, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xc9, 0xc9, 0xc9, 0xc9, 10},
{0xd9, 0xc9, 0xc9, 0xcb, 10},
{0xdd, 0xc9, 0xc9, 0xeb, 10},
{0xdd, 0xd9, 0xcb, 0xeb, 10},
{0xdd, 0xdd, 0xeb, 0xeb, 10},
{0xdd, 0xdf, 0xfb, 0xeb, 10},
{0xdd, 0xff, 0xff, 0xeb, 10},
{0xdf, 0xff, 0xff, 0xfb, 10},
{0xff, 0xff, 0xff, 0xff, 10},
/* small squares h flip : 18*/
{0x9c, 0x9c, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0xa3, 0xa3, 30},
{0xa3, 0xa3, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0x9c, 0x9c, 30},
{0x9c, 0x9c, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0xa3, 0xa3, 30},
{0xa3, 0xa3, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0x9c, 0x9c, 30},
{0x9c, 0x9c, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0xa3, 0xa3, 30},
{0xa3, 0xa3, 0x9c, 0x9c, 30},
{0xa3, 0xa3, 0xa3, 0xa3, 30},
{0x9c, 0x9c, 0x9c, 0x9c, 30},
/* small square run around: 24 */
{0x9c, 0xff, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
/* small square snake run: 42*/
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xff, 0xff, 0xa3, 15},
{0xff, 0xff, 0xff, 0x9c, 15},
{0xff, 0xff, 0x9c, 0xff, 15},
{0xff, 0xff, 0xa3, 0xff, 15},
{0xff, 0xa3, 0xff, 0xff, 15},
{0xff, 0x9c, 0xff, 0xff, 15},
{0x9c, 0xff, 0xff, 0xff, 15},
{0xa3, 0xff, 0xff, 0xff, 15},
/* fuel mode : 72*/
{0xf7, 0xff, 0xff, 0xff, 10},
{0xb7, 0xff, 0xff, 0xff, 10},
{0xb6, 0xff, 0xff, 0xff, 10},
{0xb6, 0xf7, 0xff, 0xff, 10},
{0xb6, 0xb7, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xf7, 0xff, 10},
{0xb6, 0xb6, 0xb7, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xf7, 10},
{0xb6, 0xb6, 0xb6, 0xb7, 10},
{0xb6, 0xb6, 0xb6, 0xb6, 10},
{0xb6, 0xb6, 0xb6, 0xb0, 10},
{0xb6, 0xb6, 0xb6, 0x80, 10},
{0xb6, 0xb6, 0xb0, 0x80, 10},
{0xb6, 0xb6, 0x80, 0x80, 10},
{0xb6, 0xb0, 0x80, 0x80, 10},
{0xb6, 0x80, 0x80, 0x80, 10},
{0xb0, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x00, 10},
{0x80, 0x80, 0x00, 0x00, 10},
{0x80, 0x00, 0x00, 0x00, 10},
{0x00, 0x00, 0x00, 0x00, 10},
{0xf7, 0xff, 0xff, 0xff, 10},
{0xb7, 0xff, 0xff, 0xff, 10},
{0xb6, 0xff, 0xff, 0xff, 10},
{0xb6, 0xf7, 0xff, 0xff, 10},
{0xb6, 0xb7, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xf7, 0xff, 10},
{0xb6, 0xb6, 0xb7, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xf7, 10},
{0xb6, 0xb6, 0xb6, 0xb7, 10},
{0xb6, 0xb6, 0xb6, 0xb6, 10},
{0xb6, 0xb6, 0xb6, 0xb0, 10},
{0xb6, 0xb6, 0xb6, 0x80, 10},
{0xb6, 0xb6, 0xb0, 0x80, 10},
{0xb6, 0xb6, 0x80, 0x80, 10},
{0xb6, 0xb0, 0x80, 0x80, 10},
{0xb6, 0x80, 0x80, 0x80, 10},
{0xb0, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x00, 10},
{0x80, 0x80, 0x00, 0x00, 10},
{0x80, 0x00, 0x00, 0x00, 10},
{0x00, 0x00, 0x00, 0x00, 10},
{0xf7, 0xff, 0xff, 0xff, 10},
{0xb7, 0xff, 0xff, 0xff, 10},
{0xb6, 0xff, 0xff, 0xff, 10},
{0xb6, 0xf7, 0xff, 0xff, 10},
{0xb6, 0xb7, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xff, 0xff, 10},
{0xb6, 0xb6, 0xf7, 0xff, 10},
{0xb6, 0xb6, 0xb7, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xff, 10},
{0xb6, 0xb6, 0xb6, 0xf7, 10},
{0xb6, 0xb6, 0xb6, 0xb7, 10},
{0xb6, 0xb6, 0xb6, 0xb6, 10},
{0xb6, 0xb6, 0xb6, 0xb0, 10},
{0xb6, 0xb6, 0xb6, 0x80, 10},
{0xb6, 0xb6, 0xb0, 0x80, 10},
{0xb6, 0xb6, 0x80, 0x80, 10},
{0xb6, 0xb0, 0x80, 0x80, 10},
{0xb6, 0x80, 0x80, 0x80, 10},
{0xb0, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x80, 10},
{0x80, 0x80, 0x80, 0x00, 10},
{0x80, 0x80, 0x00, 0x00, 10},
{0x80, 0x00, 0x00, 0x00, 10},
{0x00, 0x00, 0x00, 0x00, 10},
};
#define TOTALPIN 12
int seg_pin[12] = {2,3,4,5,6,7,8,9,10,11,12,13}; // using pin2~13 as output to control 7segled-4-int-1
int seg_control[4] = {7, 9, 10, 13}; // seg control pin
int seg_pos[8] = {12, 8, 5, 3, 2, 11, 6, 4}; // led pos to port list: "abcdefgh" sequence
void led_write_1c(unsigned char seg, unsigned char x)
{
int i;
//clear all control pin
for(i=0; i<4; i++)
digitalWrite(seg_control[i], LOW);
digitalWrite(seg_control[seg], HIGH); // enable dedicate segment
for(i=0; i<8; i++)
{
if((x>>i)&1) digitalWrite(seg_pos[i], HIGH);
else digitalWrite(seg_pos[i], LOW);
}
delay(2);
for(i=0; i<8; i++)
digitalWrite(seg_pos[i], HIGH);
}
void setup() {
int i;
for(i=0; i<TOTALPIN; i++)
pinMode(seg_pin[i], OUTPUT);
}
void loop() {
unsigned char i;
unsigned short counter=0;
unsigned char LED_7_SEG[4] = {0xFF, 0xFF, 0XFF, 0XFF};
unsigned int seq_pointer = 0;
while(1)
{
// play test_seq, and update LED_7_SEG[]
if(counter == 0)
{
for(i=0; i<4; i++)
LED_7_SEG[3-i] = pgm_read_byte(&test_seq[seq_pointer][i]);
}
if(pgm_read_byte(&test_seq[seq_pointer][4]) == counter)
{
counter = 0;
seq_pointer++;
if(seq_pointer == TEST_SEQ_LEN) seq_pointer = 0;
}
else
counter++;
// display LED_7_SEG[]
for(i=0; i<4; i++)
led_write_1c(i, LED_7_SEG[i]);
}
}
沒有留言:
張貼留言