Skip to content

Instantly share code, notes, and snippets.

@gfwilliams
Created May 15, 2016 19:32
Show Gist options
  • Save gfwilliams/3f41537ad1dd338ad2710e7862cc126c to your computer and use it in GitHub Desktop.
Save gfwilliams/3f41537ad1dd338ad2710e7862cc126c to your computer and use it in GitHub Desktop.
Jim's LED
@gfwilliams
Copy link
Author

var table = {
“ “:0,
0:0x3F, /* 0 /
1:0x06, /
1 /
2:0x5B, /
2 /
3:0x4F, /
3 /
4:0x66, /
4 /
5:0x6D, /
5 /
6:0x7D, /
6 /
7:0x07, /
7 /
8:0x7F, /
8 /
9:0x6F, /
9 /
“A”:0x77, /
a /
“B”:0x7C, /
b /
“C”:0x39, /
C /
“D”:0x5E, /
d /
“E”:0x79, /
E /
“F”:0x71, /
F */
];

function ledInit() {
I2C1.setup({scl:B6, sda:B7})
I2C1.writeTo(0x70, 0x21); // clock on
I2C1.writeTo(0x70, 0x81); // flash
I2C1.writeTo(0x70, 0xE0 | 15); // brightness 15
}
function ledShow(n) {
n=” “+n;
N = n.substr(-4);
I2C1.writeTo(0x70, [0,table[n[0]],0,table[n[1]],0,0,0,table[n[2]],0,table[n[3]],0]); // light some digits
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment