Components and supplies
CR2032 battery holder through hole
Jumper wires (generic)
Resistor 100 ohm
ATtiny13A-SU
Tiny AVR Programmer
CR2032 battery
Arduino UNO
LED (generic)
Slide Switch
Tools and machines
tweezers
Soldering iron (generic)
solder wire
Apps and platforms
Arduino IDE
Project description
Code
ATtinyLEDbadge.ino
arduino
1/* 2 (C)2016 FabLabAQ info@fablaquila.org 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16*/ 17 18/*~~~~~~~~~~~~ SCRIVI IL TUO NOME TRA VIRGOLETTE ~~~~~~~~~~~~*/ 19 20#define YOUR_NAME "FABLABAQ" 21 22/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 23 24#ifndef __AVR_ATtiny13__ 25 #error Selezionare ATtiny13 da: Strumenti -> Schede 26#endif 27 28// Character set 29PROGMEM const unsigned long alphabet[] = { 30 0b00000000000000000000, // 32 space 31 0b00100010001000000010, // 33 ! 32 0b01010101000000000000, // 34 " 33 0b01101111011011110110, // 35 # 34 0b01101000010000101100, // 36 $ 35 0b00001001001001001001, // 37 % 36 0b01001000010110100101, // 38 & 37 0b00100010000000000000, // 39 ' 38 0b00100100010001000010, // 40 ( 39 0b01000010001000100100, // 41 ) 40 0b01010010010100000000, // 42 * 41 0b00000000010011100100, // 43 + 42 0b00000000000000100100, // 44 , 43 0b00000000011000000000, // 45 - 44 0b00000000000000000100, // 46 . 45 0b00010011011011001000, // 47 / 46 0b01101101101110010110, // 48 0 47 0b00100110001000100111, // 49 1 48 0b11100001011010001111, // 50 2 49 0b11100001011000011110, // 51 3 50 0b00100110101011110010, // 52 4 51 0b11111000111000011110, // 53 5 52 0b01101000111010010110, // 54 6 53 0b11110001001001001000, // 55 7 54 0b01101001011010010110, // 56 8 55 0b01101001011100010110, // 57 9 56 0b00000100000001000000, // 58 : 57 0b00000100000001001000, // 59 ; 58 0b00110110110001100011, // 60 < 59 0b00001111000011110000, // 61 = 60 0b11000110001101101100, // 62 > 61 0b01001010001001000100, // 63 ? 62 0b01101011101110000110, // 64 @ 63 0b01101001111110011001, // 65 A 64 0b11101001111010011110, // 66 B 65 0b01111000100010000111, // 67 C 66 0b11101001100110011110, // 68 D 67 0b11111000111010001111, // 69 E 68 0b11111000111010001000, // 70 F 69 0b01111000101110010110, // 71 G 70 0b10011001111110011001, // 72 H 71 0b01110010001000100111, // 73 I 72 0b01110010001010100100, // 74 J 73 0b10011010110010101001, // 75 K 74 0b10001000100010001111, // 76 L 75 0b10011111111110011001, // 77 M 76 0b10011101101110011001, // 78 N 77 0b01101001100110010110, // 79 O 78 0b11101001111010001000, // 80 P 79 0b01101001101101100001, // 81 Q 80 0b11101001111010101001, // 82 R 81 0b01111000011000011110, // 83 S 82 0b01110010001000100010, // 84 T 83 0b10011001100110010110, // 85 U 84 0b10011001100110100100, // 86 V 85 0b10011001111111110110, // 87 W 86 0b10011001011010011001, // 88 X 87 0b10011001011000101100, // 89 Y 88 0b11110001001001001111, // 90 Z 89 0b01100100010001000110, // 91 [ 90 0b10001100011000110001, // 92 \\ 91 0b01100010001000100110, // 93 ] 92 0b01001010000000000000, // 94 ^ 93 0b00000000000000001111, // 95 _ 94 0b01000010000000000000, // 96 ` 95 0b01100001011110010111, // 97 a 96 0b10001000111010011110, // 98 b 97 0b00000110100010000110, // 99 c 98 0b00010001011110010111, // 100 d 99 0b01101001111010000110, // 101 e 100 0b00110100111001000100, // 102 f 101 0b00110101001100010110, // 103 g 102 0b10001000111010011001, // 104 h 103 0b00100000001000100010, // 105 i 104 0b00100010001000100100, // 106 j 105 0b10001010101011001010, // 107 k 106 0b01000100010001000100, // 108 l 107 0b00001001111110011001, // 109 m 108 0b00000000111010011001, // 110 n 109 0b00000110100110010110, // 111 o 110 0b01100101011001000100, // 112 p 111 0b00110101001100010001, // 113 q 112 0b00001010110010001000, // 114 r 113 0b00110100001000010110, // 115 s 114 0b01001110010001000010, // 116 t 115 0b00001001100110010111, // 117 u 116 0b00000101010101010010, // 118 v 117 0b00000000100111110110, // 119 w 118 0b00000000010100100101, // 120 x 119 0b00000101001100010110, // 121 y 120 0b00001111001001001111, // 122 z 121 0b01100100110001000110, // 123 { 122 0b00100010001000100010, // 124 | 123 0b01100010001100100110, // 125 } 124 0b00000101101000000000 // 126 ~ 125}; 126 127const int displayWidth = 4; 128const int displayHeight = 5; 129 130// between pixels 131const unsigned int timeout = 150; 132 133const char PROGMEM displayString[] = YOUR_NAME; 134const byte stringLength = sizeof(displayString); 135 136// The offset of our string in the display 137int offset = 0; 138unsigned long lastMillis = 0; 139unsigned long currentMillis = 0; 140 141// render the string on the given offset 142void renderString(int offset) { 143 for(byte index=0; index< (stringLength-1); index++){ 144 uint8_t pos = pgm_read_byte(&displayString[index]) - 32; 145 unsigned long gfx = pgm_read_dword(&alphabet[pos]); 146 renderCharacter(gfx, offset - index * (displayWidth + 1)); 147 } 148} 149 150 151void renderCharacter(unsigned long graphic, int charOffset) { 152 if (charOffset <= -displayWidth || charOffset > displayWidth) { 153 // off the 'screen' nothing to do 154 return; 155 } 156 157 for (byte y = 0; y < displayHeight; y++) { 158 for (byte x = 0; x < displayWidth; x++) { 159 // 3 - x to reverse order 160 setPixel(3 - x - charOffset, y, graphic & 0x1); 161 graphic = graphic >> 1; 162 } 163 } 164} 165 166// light a pixel at the given coordinates 167void setPixel(byte x, byte y, boolean ledStatus) { 168 if (x < displayWidth) { 169 if (y <= x) { 170 x++; 171 } 172 setLed(4-x, 4-y, ledStatus); 173 } 174} 175 176// turn on the pins to light a LED 177void setLed(byte vin, byte gnd, boolean ledStatus) { 178 delayMicroseconds(500); 179 180 if(ledStatus) { 181 DDRB = (0x01 << vin) | (0x01 << gnd); 182 PORTB = 0x01 << vin; 183 } 184 else { 185 DDRB = 0x00; 186 } 187} 188 189void setup() { 190} 191 192void loop() { 193 currentMillis = millis(); 194 195 renderString(offset); 196 197 if (currentMillis - lastMillis > timeout) { 198 lastMillis = currentMillis; 199 // shift string over one "pixel" 200 offset++; 201 // if it's past the length of the string, start over from the beginning 202 if (offset > (stringLength-1) * (displayWidth + 1)) { 203 offset = -displayWidth; 204 } 205 } 206} 207
ATtinyLEDbadge.ino
arduino
1/* 2 (C)2016 FabLabAQ info@fablaquila.org 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16*/ 17 18/*~~~~~~~~~~~~ SCRIVI IL TUO NOME TRA VIRGOLETTE ~~~~~~~~~~~~*/ 19 20#define YOUR_NAME "FABLABAQ" 21 22/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 23 24#ifndef __AVR_ATtiny13__ 25 #error Selezionare ATtiny13 da: Strumenti -> Schede 26#endif 27 28// Character set 29PROGMEM const unsigned long alphabet[] = { 30 0b00000000000000000000, // 32 space 31 0b00100010001000000010, // 33 ! 32 0b01010101000000000000, // 34 " 33 0b01101111011011110110, // 35 # 34 0b01101000010000101100, // 36 $ 35 0b00001001001001001001, // 37 % 36 0b01001000010110100101, // 38 & 37 0b00100010000000000000, // 39 ' 38 0b00100100010001000010, // 40 ( 39 0b01000010001000100100, // 41 ) 40 0b01010010010100000000, // 42 * 41 0b00000000010011100100, // 43 + 42 0b00000000000000100100, // 44 , 43 0b00000000011000000000, // 45 - 44 0b00000000000000000100, // 46 . 45 0b00010011011011001000, // 47 / 46 0b01101101101110010110, // 48 0 47 0b00100110001000100111, // 49 1 48 0b11100001011010001111, // 50 2 49 0b11100001011000011110, // 51 3 50 0b00100110101011110010, // 52 4 51 0b11111000111000011110, // 53 5 52 0b01101000111010010110, // 54 6 53 0b11110001001001001000, // 55 7 54 0b01101001011010010110, // 56 8 55 0b01101001011100010110, // 57 9 56 0b00000100000001000000, // 58 : 57 0b00000100000001001000, // 59 ; 58 0b00110110110001100011, // 60 < 59 0b00001111000011110000, // 61 = 60 0b11000110001101101100, // 62 > 61 0b01001010001001000100, // 63 ? 62 0b01101011101110000110, // 64 @ 63 0b01101001111110011001, // 65 A 64 0b11101001111010011110, // 66 B 65 0b01111000100010000111, // 67 C 66 0b11101001100110011110, // 68 D 67 0b11111000111010001111, // 69 E 68 0b11111000111010001000, // 70 F 69 0b01111000101110010110, // 71 G 70 0b10011001111110011001, // 72 H 71 0b01110010001000100111, // 73 I 72 0b01110010001010100100, // 74 J 73 0b10011010110010101001, // 75 K 74 0b10001000100010001111, // 76 L 75 0b10011111111110011001, // 77 M 76 0b10011101101110011001, // 78 N 77 0b01101001100110010110, // 79 O 78 0b11101001111010001000, // 80 P 79 0b01101001101101100001, // 81 Q 80 0b11101001111010101001, // 82 R 81 0b01111000011000011110, // 83 S 82 0b01110010001000100010, // 84 T 83 0b10011001100110010110, // 85 U 84 0b10011001100110100100, // 86 V 85 0b10011001111111110110, // 87 W 86 0b10011001011010011001, // 88 X 87 0b10011001011000101100, // 89 Y 88 0b11110001001001001111, // 90 Z 89 0b01100100010001000110, // 91 [ 90 0b10001100011000110001, // 92 \\ 91 0b01100010001000100110, // 93 ] 92 0b01001010000000000000, // 94 ^ 93 0b00000000000000001111, // 95 _ 94 0b01000010000000000000, // 96 ` 95 0b01100001011110010111, // 97 a 96 0b10001000111010011110, // 98 b 97 0b00000110100010000110, // 99 c 98 0b00010001011110010111, // 100 d 99 0b01101001111010000110, // 101 e 100 0b00110100111001000100, // 102 f 101 0b00110101001100010110, // 103 g 102 0b10001000111010011001, // 104 h 103 0b00100000001000100010, // 105 i 104 0b00100010001000100100, // 106 j 105 0b10001010101011001010, // 107 k 106 0b01000100010001000100, // 108 l 107 0b00001001111110011001, // 109 m 108 0b00000000111010011001, // 110 n 109 0b00000110100110010110, // 111 o 110 0b01100101011001000100, // 112 p 111 0b00110101001100010001, // 113 q 112 0b00001010110010001000, // 114 r 113 0b00110100001000010110, // 115 s 114 0b01001110010001000010, // 116 t 115 0b00001001100110010111, // 117 u 116 0b00000101010101010010, // 118 v 117 0b00000000100111110110, // 119 w 118 0b00000000010100100101, // 120 x 119 0b00000101001100010110, // 121 y 120 0b00001111001001001111, // 122 z 121 0b01100100110001000110, // 123 { 122 0b00100010001000100010, // 124 | 123 0b01100010001100100110, // 125 } 124 0b00000101101000000000 // 126 ~ 125}; 126 127const int displayWidth = 4; 128const int displayHeight = 5; 129 130// between pixels 131const unsigned int timeout = 150; 132 133const char PROGMEM displayString[] = YOUR_NAME; 134const byte stringLength = sizeof(displayString); 135 136// The offset of our string in the display 137int offset = 0; 138unsigned long lastMillis = 0; 139unsigned long currentMillis = 0; 140 141// render the string on the given offset 142void renderString(int offset) { 143 for(byte index=0; index< (stringLength-1); index++){ 144 uint8_t pos = pgm_read_byte(&displayString[index]) - 32; 145 unsigned long gfx = pgm_read_dword(&alphabet[pos]); 146 renderCharacter(gfx, offset - index * (displayWidth + 1)); 147 } 148} 149 150 151void renderCharacter(unsigned long graphic, int charOffset) { 152 if (charOffset <= -displayWidth || charOffset > displayWidth) { 153 // off the 'screen' nothing to do 154 return; 155 } 156 157 for (byte y = 0; y < displayHeight; y++) { 158 for (byte x = 0; x < displayWidth; x++) { 159 // 3 - x to reverse order 160 setPixel(3 - x - charOffset, y, graphic & 0x1); 161 graphic = graphic >> 1; 162 } 163 } 164} 165 166// light a pixel at the given coordinates 167void setPixel(byte x, byte y, boolean ledStatus) { 168 if (x < displayWidth) { 169 if (y <= x) { 170 x++; 171 } 172 setLed(4-x, 4-y, ledStatus); 173 } 174} 175 176// turn on the pins to light a LED 177void setLed(byte vin, byte gnd, boolean ledStatus) { 178 delayMicroseconds(500); 179 180 if(ledStatus) { 181 DDRB = (0x01 << vin) | (0x01 << gnd); 182 PORTB = 0x01 << vin; 183 } 184 else { 185 DDRB = 0x00; 186 } 187} 188 189void setup() { 190} 191 192void loop() { 193 currentMillis = millis(); 194 195 renderString(offset); 196 197 if (currentMillis - lastMillis > timeout) { 198 lastMillis = currentMillis; 199 // shift string over one "pixel" 200 offset++; 201 // if it's past the length of the string, start over from the beginning 202 if (offset > (stringLength-1) * (displayWidth + 1)) { 203 offset = -displayWidth; 204 } 205 } 206} 207
Full source
Downloadable files
Complete sources
schematic, board and firmware
https://github.com/FabLabAQ/Gadgets/tree/master/ATtiny%20LED%20badge
PCB
this is just the proposed PCB
http://oshpark.com/shared_projects/tQrBepxw
PCB
this is just the proposed PCB
http://oshpark.com/shared_projects/tQrBepxw
Complete sources
schematic, board and firmware
https://github.com/FabLabAQ/Gadgets/tree/master/ATtiny%20LED%20badge
Comments
Only logged in users can leave comments
Masaniello
0 Followers
•0 Projects
Table of contents
Intro
5
0