/* Example arduino program to burn a 4K program into a 28C64 (8k) parallel EEPROM. DISCLAIMER: Use at your own risk! */ /* writes 4k (pilotx4stella) to chip --------------------------------- 1. writes a byte, then reads and verifies. led13 is on all the time. 2. if a verify fails, led13 blinks 20x long and 20x short, then that byte is written and verified again. Thean go ahead to 2. again. 3. if a previously failed verify works correct after a repeated write, led13 shows 3 pulses of short blinks (6x each) and then the program continues to write the next byte (go ahead to 1. again) 4. at the end the led goes off for one minute. 5. Switch the board off before this minute is over because otherwise the program is started again and will write the 4k again. */ byte bin[4096] = { 120,216,162,255,154,169,0,149,0,202,208,251,169,40,133,6, 133,7,169,53,133,4,133,5,169,48,133,10,165,190,41,240, 9,6,133,190,169,8,133,22,169,30,133,24,169,0,141,129, 2,88,169,0,133,1,169,2,133,0,133,2,165,128,41,15, 170,189,49,24,133,8,133,2,169,42,141,150,2,133,2,169, 0,133,0,133,9,165,190,41,15,201,6,208,36,32,144,21, 32,152,20,169,0,133,187,133,188,165,190,41,240,9,4,133, 190,165,196,41,240,133,196,32,57,20,169,17,133,249,76,15, 17,201,5,208,20,32,144,21,32,152,20,32,57,20,165,190, 41,240,9,0,133,190,76,15,17,201,3,208,13,32,127,20, 144,5,230,196,32,98,20,76,15,17,201,1,208,12,32,186, 20,32,206,21,32,155,22,76,15,17,201,7,208,36,198,237, 240,3,76,15,17,165,196,41,240,9,1,133,196,165,190,41, 240,9,5,133,190,165,189,41,15,201,5,240,2,230,189,76, 15,17,201,0,208,6,32,127,20,76,15,17,201,4,208,31, 32,206,21,32,155,22,165,187,41,15,201,13,208,14,165,187, 41,240,133,187,165,190,41,240,9,3,133,190,76,15,17,173, 132,2,208,251,165,190,41,15,201,2,208,53,160,0,162,0, 134,27,134,28,134,29,134,30,134,31,169,40,133,8,133,2, 200,152,230,236,101,236,170,189,48,16,133,13,189,97,16,133, 14,189,146,16,133,15,192,26,208,228,169,102,133,8,76,177, 17,160,0,162,0,169,255,133,29,133,30,133,31,133,2,181, 128,133,13,185,185,31,133,27,181,146,133,14,185,186,31,133, 28,181,164,133,15,181,182,133,13,181,200,133,14,181,218,133, 15,152,24,101,239,74,74,74,170,181,128,133,13,41,15,154, 170,189,49,24,133,8,186,181,146,133,14,181,164,133,15,181, 182,133,13,181,200,133,14,181,218,133,15,200,200,192,26,208, 172,133,2,181,128,133,13,169,0,133,29,133,30,181,146,133, 14,169,0,133,31,181,164,133,15,181,182,133,13,181,200,133, 14,181,218,133,15,152,24,101,239,74,74,74,170,181,128,133, 13,41,15,154,170,189,49,24,133,8,186,181,146,133,14,181, 164,133,15,181,182,133,13,181,200,133,14,181,218,133,15,200, 200,192,132,208,172,133,2,169,0,133,13,133,14,133,15,162, 255,154,165,189,41,15,170,189,249,23,133,245,133,2,133,2, 133,2,133,2,133,2,133,2,133,2,133,2,133,2,198,250, 165,250,41,15,208,31,165,249,240,23,165,249,198,249,170,189, 211,31,133,21,74,74,74,74,133,23,169,6,133,25,76,85, 18,169,0,133,25,133,2,133,2,133,2,169,176,133,9,169, 0,133,13,133,14,133,15,169,26,133,8,133,2,162,4,32, 176,23,133,2,144,3,32,176,23,133,2,144,3,32,176,23, 133,2,144,3,32,176,23,133,2,144,3,32,176,23,133,2, 160,0,169,0,133,244,32,21,23,32,126,23,200,192,5,208, 248,133,2,169,10,133,244,32,21,23,32,126,23,200,192,10, 208,248,133,2,169,20,133,244,32,21,23,32,126,23,200,192, 15,208,248,133,2,169,30,133,244,32,21,23,32,126,23,200, 192,20,208,248,133,2,169,40,133,244,32,21,23,32,126,23, 200,192,25,208,248,133,2,169,102,133,8,169,0,133,13,133, 14,133,15,133,2,133,2,133,2,165,196,41,15,10,170,165, 246,221,173,31,208,58,165,247,221,174,31,208,51,165,196,41, 15,201,5,240,18,24,105,1,69,196,41,15,69,196,133,196, 169,9,133,249,76,64,19,133,2,165,190,41,15,201,7,240, 17,165,190,41,240,9,7,133,190,169,250,133,237,76,66,19, 133,2,133,2,133,2,169,0,133,9,133,13,133,14,133,15, 165,187,41,15,201,15,240,9,165,239,208,74,230,187,76,166, 19,165,188,41,15,201,15,240,6,165,239,208,57,230,188,165, 190,41,15,201,1,208,47,165,188,41,15,201,15,208,39,165, 2,48,19,165,3,48,15,165,4,48,11,165,5,48,7,165, 6,48,3,76,166,19,165,190,41,240,9,2,133,190,169,6, 133,26,169,120,133,237,133,2,133,44,165,190,41,15,201,2, 208,44,165,237,74,74,74,74,41,7,133,26,198,237,208,30, 198,189,165,189,41,15,208,11,165,190,41,240,9,6,133,190, 76,222,19,165,190,41,240,9,5,133,190,76,222,19,165,190, 41,15,201,1,240,4,201,4,208,69,230,239,165,239,201,8, 208,61,169,0,133,239,162,0,133,2,181,129,149,128,181,147, 149,146,181,165,149,164,181,182,41,15,149,182,181,183,41,240, 21,182,149,182,181,201,149,200,181,219,149,218,232,224,17,208, 215,169,0,133,9,160,11,133,2,136,208,251,76,50,16,160, 28,133,2,136,208,251,76,50,16,165,196,41,15,10,170,189, 171,31,133,246,189,172,31,133,247,165,193,41,240,133,193,165, 194,41,240,133,194,165,191,41,240,133,191,165,192,41,240,133, 192,96,169,0,133,187,133,188,165,189,41,240,9,3,133,189, 162,4,181,182,41,240,149,182,202,208,247,76,57,20,96,169, 0,133,239,173,128,2,41,240,201,240,240,10,165,190,41,240, 9,1,133,190,56,96,24,96,162,0,169,0,149,128,232,224, 54,208,249,162,0,149,200,232,224,36,208,249,162,0,181,182, 41,15,149,182,232,224,18,208,245,96,165,194,73,8,133,194, 165,194,41,8,240,5,133,43,76,139,21,173,128,2,10,176, 3,76,235,20,10,176,3,76,11,21,10,176,3,76,88,21, 10,176,3,76,43,21,133,43,76,139,21,169,240,133,32,133, 33,133,34,133,35,133,36,165,238,201,138,208,5,133,43,76, 8,21,230,236,230,237,230,238,76,139,21,169,16,133,32,133, 33,133,34,133,35,133,36,165,237,201,6,208,5,133,43,76, 40,21,198,236,198,237,198,238,76,139,21,169,16,133,32,169, 240,133,33,169,0,133,34,133,35,133,36,165,237,201,6,208, 5,133,43,76,139,21,165,238,201,138,208,5,133,43,76,139, 21,198,237,230,238,76,139,21,169,16,133,33,169,240,133,32, 169,0,133,34,133,35,133,36,165,237,24,105,16,197,236,208, 5,133,43,76,139,21,165,236,24,105,24,197,238,208,5,133, 43,76,139,21,198,238,230,237,76,139,21,133,2,133,42,96, 162,0,160,3,169,208,32,232,31,162,2,160,4,169,160,32, 232,31,162,4,160,5,169,16,32,232,31,162,3,160,5,169, 144,32,232,31,162,1,160,6,169,32,32,232,31,133,2,133, 42,169,52,133,237,169,68,133,236,169,92,133,238,96,165,239, 240,12,41,4,240,1,96,165,194,41,2,208,1,96,162,10, 165,193,41,15,133,244,165,191,10,10,10,10,69,192,41,240, 69,192,168,240,3,76,20,22,169,6,133,245,169,0,230,244, 198,244,240,64,38,248,42,198,245,208,245,198,244,168,165,194, 73,1,133,194,192,63,208,11,165,194,41,252,133,194,160,0, 76,124,22,192,62,240,85,192,45,176,60,192,0,240,201,165, 194,74,38,235,38,217,38,199,38,181,38,163,202,240,30,136, 208,237,240,180,72,152,72,160,0,177,246,133,248,230,246,208, 2,230,247,169,8,133,244,104,168,104,76,4,22,136,165,194, 9,2,133,194,76,124,22,152,56,233,45,69,195,41,15,69, 195,133,195,165,194,73,1,133,194,76,248,21,152,69,192,41, 15,69,192,133,192,152,74,74,74,74,69,191,41,15,69,191, 133,191,165,193,41,240,5,244,133,193,96,165,239,201,7,240, 1,96,165,194,41,2,208,1,96,162,4,6,199,38,181,38, 163,38,145,202,208,245,6,145,38,145,38,145,38,145,162,8, 24,38,181,42,202,208,250,162,8,42,102,181,202,208,250,162, 8,24,38,235,42,202,208,250,162,8,42,102,235,202,208,250, 162,4,24,38,145,42,202,208,250,42,42,42,42,162,4,42, 102,145,202,208,250,162,4,24,38,199,42,202,208,250,42,42, 42,42,162,4,42,102,199,202,208,250,165,145,69,195,41,240, 69,195,133,145,96,169,0,133,13,133,14,133,15,165,182,41, 15,24,101,244,170,189,255,23,133,240,165,184,41,15,24,101, 244,170,189,255,23,41,15,133,241,165,183,41,15,24,101,244, 170,189,255,23,10,10,10,10,5,241,133,241,165,186,41,15, 24,101,244,170,189,255,23,41,240,133,242,165,185,41,15,24, 101,244,170,189,255,23,74,74,74,74,5,242,133,242,165,196, 41,15,24,101,244,170,189,255,23,41,240,133,243,96,133,2, 165,240,133,13,165,241,133,14,165,242,133,15,162,0,196,245, 176,16,234,134,13,234,234,234,185,224,23,133,14,165,243,133, 15,96,134,13,234,234,234,234,234,134,14,165,243,133,15,96, 165,190,41,15,201,1,240,1,96,165,239,240,1,96,56,181, 182,41,15,105,0,201,10,208,13,181,182,41,240,149,182,202, 240,2,56,96,24,96,85,182,41,15,85,182,149,182,24,96, 90,90,126,90,90,90,90,126,90,90,90,90,126,90,90,90, 90,126,90,90,90,90,126,90,90,0,5,10,15,20,25,231, 66,231,231,36,231,231,231,231,231,165,102,129,129,165,36,36, 129,165,165,165,66,231,195,231,231,231,66,231,231,165,66,36, 129,129,129,165,66,165,129,231,231,231,231,129,231,231,66,231, 231,118,28,40,52,72,92,102,136,156,184,200,124,204,196,6, 14,2,143,237,0,17,3,8,16,133,16,33,131,8,32,130, 20,32,129,8,65,129,24,48,130,8,32,130,8,16,129,8, 64,130,8,48,134,16,48,130,8,16,129,8,64,130,8,48, 135,8,65,66,8,16,132,8,32,131,8,112,132,16,48,129, 8,64,130,8,48,134,16,48,133,8,17,65,24,48,133,8, 32,130,8,80,129,20,33,4,8,80,130,8,16,40,255,255, 255,255,255,255,255,129,99,4,16,65,6,49,99,4,16,65, 6,49,99,4,16,65,6,60,6,120,182,198,255,241,156,45, 195,27,53,163,216,69,116,151,77,85,21,77,100,214,27,255, 204,85,37,145,89,5,207,96,246,14,100,246,15,93,21,83, 73,100,85,252,36,149,81,69,82,93,26,55,10,1,2,33, 51,1,252,55,134,8,24,1,8,16,176,45,66,127,49,53, 146,93,37,210,93,37,147,89,53,147,89,48,191,81,48,127, 85,32,127,81,32,191,77,53,19,81,53,19,81,53,19,81, 53,19,81,52,212,81,53,20,73,100,25,47,240,219,49,210, 222,41,242,33,27,240,98,23,240,80,5,33,80,9,17,80, 13,16,255,5,0,210,11,240,143,13,32,191,8,112,71,13, 33,6,12,96,210,16,81,68,17,33,69,12,81,18,85,53, 19,81,52,212,23,243,148,73,84,149,73,84,87,57,147,28, 42,2,36,18,140,192,96,17,1,12,17,1,104,65,68,104, 32,130,12,32,130,96,128,72,96,17,1,12,17,1,7,0, 83,93,53,211,85,115,63,255,255,255,25,116,151,73,84,212, 85,37,209,96,243,191,255,255,255,252,164,23,73,85,19,89, 22,15,104,230,204,116,167,201,128,120,132,252,34,2,52,18, 134,28,66,195,40,81,197,36,66,131,255,255,255,255,255,255, 252,34,4,36,66,131,252,50,3,36,66,134,84,34,199,128, 79,196,124,167,138,116,199,12,108,230,143,97,5,210,20,17, 193,25,65,65,28,17,76,255,255,255,252,148,204,252,133,82, 89,22,15,108,215,133,252,56,133,144,47,195,136,88,195,252, 56,133,144,47,194,140,73,3,252,41,4,140,63,193,144,88, 195,255,240,226,22,64,191,14,33,99,15,240,101,10,112,104, 255,255,255,255,255,255,255,48,100,22,2,26,57,116,84,81, 53,146,89,21,208,87,255,195,61,132,22,255,240,145,89,242, 40,255,144,22,44,125,192,80,224,130,84,240,67,81,68,213, 81,69,79,4,53,142,8,32,186,1,98,199,224,6,132,148, 41,68,128,193,179,5,37,208,91,240,145,93,37,147,85,69, 21,77,100,63,9,115,255,252,33,129,36,17,206,255,255,194, 24,18,65,32,241,193,36,17,205,255,240,135,4,144,72,60, 112,73,4,115,63,252,49,193,36,18,15,28,18,65,28,191, 255,16,112,73,4,131,199,4,144,71,43,255,197,28,18,65, 32,241,193,36,17,201,255,241,135,4,144,72,60,112,73,4, 114,63,252,113,193,36,18,15,28,18,65,28,127,255,252,134, 71,255,255,255,255,255,200,97,21,200,252,149,137,252,149,84, 77,100,88,60,223,255,2,141,64,12,101,70,20,164,74,8, 32,66,8,32,66,60,32,66,8,32,66,12,132,200,24,17, 1,84,17,1,19,51,15,55,255,255,255,255,255,255,242,209, 89,53,21,73,116,25,57,179,8,8,144,136,40,128,201,12, 130,8,16,145,8,24,129,73,20,129,71,24,145,135,20,97, 201,28,96,255,8,113,137,24,113,72,20,145,72,20,145,9, 16,145,137,12,144,201,32,144,137,8,146,157,49,179,153,65, 116,149,81,53,146,47,255,201,88,231,70,163,176,27,29,227, 90,20,81,88,32,49,150,32,50,22,24,50,24,20,81,90, 52,60,0,108,17,65,136,81,255,2,143,255,255,191,192,28, 119,140,104,81,69,96,128,198,88,128,200,88,96,200,96,81, 69,104,214,48,0,96,69,6,33,92,252,10,63,255,191,255, 1,177,222,53,161,69,21,130,3,25,98,3,33,97,131,33, 129,69,21,163,67,192,6,193,20,24,133,31,240,40,204,56, 12,93,36,214,65,147,207,255,242,81,89,68,152,57,242,34, 22,48,255,10,64,191,255,255,255,255,240,165,10,81,36,11, 255,255,252,25,66,156,26,63,255,255,255,180,9,194,148,72, 198,132,135,202,116,198,206,101,5,210,85,68,214,69,131,205, 255,130,209,89,52,215,61,179,30,34,33,38,6,143,255,255, 255,255,255,255,255,255,255,255,255,192,13,4,176,78,252,3, 3,36,51,127,255,255,255,196,2,197,28,83,60,0,192,201, 12,223,255,224,2,197,28,83,63,2,143,255,255,255,255,255, 255,255,255,255,255,255,255,237,6,64,255,255,241,93,27,255, 255,37,98,127,255,243,79,51,255,255,252,214,66,255,255,255, 255,255,255,255,255,215,60,47,255,255,255,204,104,47,255,255, 255,255,255,255,255,255,243,15,55,255,255,255,255,255,255,240, 90,55,255,255,255,255,255,255,255,255,252,19,216,255,255,255, 255,255,193,148,47,255,255,255,255,255,255,192,163,253,64,28, 41,66,4,23,130,12,32,193,119,240,130,12,48,93,8,32, 130,4,32,92,24,32,66,5,192,130,8,32,66,5,192,130, 12,48,93,252,32,194,12,24,194,4,25,66,124,10,45,3, 240,24,67,255,255,252,5,20,255,255,255,2,143,0,124,56, 196,31,32,21,45,194,201,236,5,193,16,18,249,1,53,89, 4,80,69,5,192,69,4,80,65,204,5,83,252,36,211,255, 255,255,255,255,255,252,33,65,28,17,83,255,240,147,85,69, 21,77,100,151,73,116,151,73,116,151,73,116,151,73,116,151, 73,116,150,77,85,20,85,49,191,255,255,207,20,17,193,20, 111,255,61,49,191,255,255,255,13,241,191,255,255,195,140,47, 255,255,255,255,255,255,255,255,255,255,252,10,63,255,255,255, 235,240,16,4,112,79,255,240,15,8,112,156,12,112,218,16, 113,24,20,113,86,24,113,138,2,143,0,40,64,66,28,32, 68,72,129,200,72,64,66,28,32,68,36,10,58,8,129,137, 24,128,127,255,255,255,255,255,255,8,129,74,24,128,200,20, 161,73,7,255,255,252,34,5,36,82,129,255,255,255,8,129, 73,16,176,127,8,129,10,16,176,200,16,145,12,12,129,9, 16,176,191,252,34,4,36,51,4,32,66,67,44,82,3,40, 50,195,252,34,3,36,51,5,32,50,67,44,79,194,32,50, 66,48,98,2,40,34,197,255,240,136,8,160,76,28,128,75, 4,193,200,4,176,75,32,128,87,34,1,191,252,39,199,255, 255,193,124,143,255,255,255,255,5,68,255,252,35,215,255,255, 255,255,255,192,116,34,117,3,240,25,41,195,153,65,116,149, 81,53,104,255,255,252,255,255,255,255,255,255,252,2,65,52, 22,3,44,51,255,0,144,77,5,128,203,12,240,40,255,255, 255,255,255,192,56,19,129,92,51,3,39,240,14,4,224,87, 12,192,201,2,143,192,20,25,131,135,240,5,6,96,225,1, 16,74,5,176,200,12,175,192,68,18,129,108,50,3,40,10, 63,255,255,255,252,8,193,64,18,129,40,51,131,32,50,67, 56,50,3,40,20,1,40,18,131,56,50,3,56,26,63,255, 240,39,6,143,255,252,71,71,255,242,207,59,255,255,255,255, 255,255,255,255,25,146,127,252,10,63,255,31,192,44,19,193, 48,113,1,60,17,81,4,19,193,5,115,215,4,19,193,5, 33,1,60,17,71,44,19,193,48,10,58,3,255,200,120,47, 255,252,245,5,252,10,45,0,82,21,20,67,19,4,48,67, 57,32,65,4,16,66,65,16,65,4,16,66,65,16,67,4, 17,196,29,0,129,8,17,130,8,33,144,20,31,199,16,116, 1,12,16,144,68,48,65,9,4,66,4,32,206,72,48,65, 20,180,193,12,17,199,84,90,122,72,241,255,14,17,63,255, 240,40,224,58,2,160,24,129,20,24,65,4,17,1,128,48, 65,12,23,198,8,23,239,45,0,129,20,16,130,44,240,66, 28,32,65,45,0,129,20,16,130,182,143,194,12,16,193,8, 16,65,12,16,193,12,16,194,8,48,68,4,48,65,4,16, 129,4,16,67,4,16,65,4,16,66,4,32,69,4,64,67, 4,16,65,16,16,65,4,16,130,12,32,66,12,48,68,4, 48,65,4,16,65,8,16,65,4,16,193,4,16,66,4,64, 72,12,16,193,4,16,129,12,16,65,4,16,65,4,32,66, 8,64,106,255,255,255,255,255,255,252,0,65,24,161,24,48, 26,248,27,93,29,166,31,169,31,56,28,124,62,124,62,254, 127,254,127,239,247,239,247,254,127,254,127,124,62,124,62,56, 28,0,0,0,14,58,58,58,58,30,30,30,30,122,30,122, 30,122,30,122,30,0,0,0,133,2,200,234,234,234,234,234, 234,136,208,253,149,16,149,32,96,0,0,16,0,16,0,16 }; // Data bus: int IOBASE = 30; int IO0 = 30; int IO1 = 31; int IO2 = 32; int IO3 = 33; int IO4 = 34; int IO5 = 35; int IO6 = 36; int IO7 = 37; // Address bus: int ADBASE = 40; int AD0 = ADBASE+0; int AD1 = ADBASE+1; int AD2 = ADBASE+2; int AD3 = ADBASE+3; int AD4 = ADBASE+4; int AD5 = ADBASE+5; int AD6 = ADBASE+6; int AD7 = ADBASE+7; int AD8 = ADBASE+8; int AD9 = ADBASE+9; int AD10 = ADBASE+10; int AD11 = ADBASE+11; int AD12 = ADBASE+12; // control pins: int _CE = 22; int _OE = 24; int _WE = 26; // other: int led = 13; int by = 0; int ad = 0; void setup() { datain(); for (int i=0;i<13;i++) { pinMode(ADBASE+i,OUTPUT); } pinMode(_CE, OUTPUT); pinMode(_OE, OUTPUT); pinMode(_WE, OUTPUT); pinMode(led, OUTPUT); digitalWrite(_WE, HIGH); // no write digitalWrite(_OE, LOW); // enable output digitalWrite(_CE, LOW); // select chip digitalWrite(led, LOW); // now we should see data according to the provided adresses } void loop() { byte bt = 0; byte rd = 0; int ok = 0; digitalWrite(led,HIGH); for (int i=0; i<4096; i++) { // write: bt = bin[i]; store(i,bt); delay(50); // vfy: rd = (byte)readByte(i); if (rd != bt) { // error! ok = 0; while (!ok) { // blink: for (int j=0;j<20;j++) { digitalWrite(led,HIGH); delay(300); digitalWrite(led,LOW); delay(300); } for (int j=0;j<20;j++) { digitalWrite(led,HIGH); delay(30); digitalWrite(led,LOW); delay(30); } //write again: store(i,bt); delay(50); // vfy again rd = (byte)readByte(i); if (rd == bt) ok = 1; } // final success: for (int j=0;j<6;j++) { digitalWrite(led,HIGH); delay(30); digitalWrite(led,LOW); delay(30); } delay(300); for (int j=0;j<6;j++) { digitalWrite(led,HIGH); delay(30); digitalWrite(led,LOW); delay(30); } delay(300); for (int j=0;j<6;j++) { digitalWrite(led,HIGH); delay(30); digitalWrite(led,LOW); delay(30); } // goon with next byte digitalWrite(led,HIGH); } } // finished. digitalWrite(led,LOW); delay(60000); // 1 minute } void store(int a, byte b) { // now write to a: digitalWrite(_OE, HIGH); // disable output delay(1); setAdr(a); dataout(); setByte(b); // set data byte delay(1); digitalWrite(_WE, LOW); // enable write, address is latched delay(1); digitalWrite(_WE, HIGH); // write disable, data is latched and stored delay(2); setByte(0); // now the data should be stored } byte show(int a) { // read first from a: datain(); digitalWrite(_WE, HIGH); // no write digitalWrite(_OE, LOW); // enable output setAdr(a); delay(1); // now we should see the data of adr 5 } int readByte(int adr) { digitalWrite(_WE, HIGH); // no write digitalWrite(_OE, LOW); // enable output datain(); setAdr(adr); delay(2); int b = 0; for (int j=7;j>=0;j--) { b = 2*b + digitalRead(IOBASE+j); } return b; } void datain() { for (int i=0;i<8;i++) { pinMode(IOBASE+i,INPUT); } } void dataout() { for (int i=0;i<8;i++) { pinMode(IOBASE+i,OUTPUT); } } void setByte(byte b) { digitalWrite(IO0,(b&1 ? HIGH : LOW)); digitalWrite(IO1,(b&2 ? HIGH : LOW)); digitalWrite(IO2,(b&4 ? HIGH : LOW)); digitalWrite(IO3,(b&8 ? HIGH : LOW)); digitalWrite(IO4,(b&16 ? HIGH : LOW)); digitalWrite(IO5,(b&32 ? HIGH : LOW)); digitalWrite(IO6,(b&64 ? HIGH : LOW)); digitalWrite(IO7,(b&128 ? HIGH : LOW)); } void setAdr(int a) { digitalWrite(AD0,(a&1 ? HIGH : LOW)); digitalWrite(AD1,(a&2 ? HIGH : LOW)); digitalWrite(AD2,(a&4 ? HIGH : LOW)); digitalWrite(AD3,(a&8 ? HIGH : LOW)); digitalWrite(AD4,(a&16 ? HIGH : LOW)); digitalWrite(AD5,(a&32 ? HIGH : LOW)); digitalWrite(AD6,(a&64 ? HIGH : LOW)); digitalWrite(AD7,(a&128 ? HIGH : LOW)); digitalWrite(AD8,(a&256 ? HIGH : LOW)); digitalWrite(AD9,(a&512 ? HIGH : LOW)); digitalWrite(AD10,(a&1024 ? HIGH : LOW)); digitalWrite(AD11,(a&2048 ? HIGH : LOW)); digitalWrite(AD12,(a&4096 ? HIGH : LOW)); }