Intellivision controller adapter (Arduino)
This project is to take an existing intellivision controller and using an Arduino micro map it to keystrokes to be used in cool CV emulator
Components and supplies
1
intellivision controller
1
Arduino Micro
Apps and platforms
1
Arduino IDE
Project description
Code
Intellivision-controller.ino
arduino
1#include <Joystick.h> 2/* 3 * This code takes inputs from a 9 pin intellivision controller and converts it into joystick buttons, since all points on disc are just buttons. 4 * Below is an ec=xample of the intellivision ciontroller layout 5 * 6 * +---+---+---+ 7 * X | 1 | 2 | 3 | X 8 * +---+---+---+ 9 * Y | 4 | 5 | 6 | Z 10 * +---+---+---+ 11 * | 7 | 8 | 9 | 12 * +---+---+---+ 13 * | C | 0 | E | 14 * +---+---+---+ 15 * o p a b c 16 * n \| / d 17 * m - o - e 18 * l / | \ f 19 * k j i h g 20 * 21 * Mattel DB9 pinout (intv 2) 22 * ------------- ------------------ 23 * \5 4 3 2 1 / \Gr Wh Bl Bk Yl / 24 * \9 8 7 6 / \ Rd Br Gy Or / 25 * --------- ------------- 26 * 27 * Mattel hardwire pinout (intv 1) 28 * ___________________________________ 29 * | 5 | 4 | 3 | 2 | 1 | 9 | 8 | 7 | 6 | 30 * ----------------------------------- 31 * Br | R | O | Y| Gnd | B | Bk| G | W 32 * 33 * Intellivision (DB9) - Arduino (pins) - pin Array position 34 * 1 Yellow - D2 - Yellow - (0) 35 * 2 Black - GND - Black 36 * 3 Blue - D3 - Blue - (1) 37 * 4 White - D4 - White - (2) 38 * 5 Green - D5 - Green - (3) 39 * 6 Pink - D6 - Orange - (4) 40 * 7 Grey - D7 - Grey - (5) 41 * 8 Brown - D8 - Brown - (6) 42 * 9 Red - D9 - Red - (7) 43 * 44 */ 45 46Joystick_ Joystick1; 47Joystick_ Joystick2; 48// Arduino Micro digital pins 49//int myPin1[8]={5,4,3,2,9,8,7,6}; //Intv1 layout 50int myPin1[8]={2,3,4,5,6,7,8,9}; //Intv 2 layout 51int myPin2[8]={0,0,0,0,0,0,0,0}; 52unsigned char wire1; 53unsigned char wire2; 54unsigned char oldwire1=B11111111; 55unsigned char buttonstate1; 56int ledPin = 13; 57bool ledOn = 0; 58// Last state of buttons 59int lastButtonState1[31] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 60int lastButtonState2[31] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 61 62 63void setup() { 64 // put your setup code here, to run once: 65 // set pin 2-9 as inputy and pull high 66 for (int t=0; t<8; t++) { 67 pinMode ( myPin1[t] , INPUT_PULLUP ); // declare led as output 68 Serial.print(myPin1[t]);Serial.println('.-z.'); 69 digitalWrite(ledPin, LOW); // turn off led 70 } 71 Joystick1.begin(); 72 Joystick2.begin(); 73 int done = 0; 74} 75 76/* 77 void printBits(byte myByte){ 78 for(byte mask = 0x80; mask; mask >>= 1){ 79 if(mask & myByte) 80 Serial.print('1'); 81 else 82 Serial.print('0'); 83 } 84 Serial.println('.'); 85 } 86*/ 87void loop() { 88 // put your main code here, to run repeatedly: 89 Serial.print("Test Wire In");Serial.println('.'); 90 wire1 = 0; 91 for (int t=0; t<8; t++) { 92 Serial.print(digitalRead(myPin1[t]), DEC);Serial.println(".-."); 93 wire1 |= ((digitalRead(myPin1[t]) == LOW ? 1:0)<<(7-t)); 94 } 95 delay(10); 96 Serial.print("Test Wire In");Serial.println('.'); 97 //wire1=10000001; // clear wire byte from Controller 1 98 wire2=0; // clear wire byte from Controller 2 99 /* 100 for(byte mask = 0x80; mask; mask >>= 1){ 101 if(mask & wire1){ 102 Serial.print('1'); 103 } 104 else{ 105 Serial.print('0'); 106 } 107 Serial.println('.'); 108 } 109 */ 110 // for(int t=0; t<8; t++){ 111 // wire1 != ((digitalRead(myPin1[t])==LOW ? 0:1)<<(7-t)); // read wire from Controller 1 112 // wire2 != ((digitalRead(myPin2[t])==LOW ? 0:1)<<(7-t)); // read wire from Controller 2 113 // } 114 if (wire1 != oldwire1){ 115 //Joystick1.releaseAll(); 116 oldwire1 = wire1; 117 ledOn = 1-ledOn; 118 digitalWrite(ledPin, ledOn); //turn off led 119 } 120 //currentButtonState1 = wire1; 121 //wire1='10000101'; 122/* 123 Serial.print('wire1');Serial.println('.'); 124 for(int i =0; i < strlen(wire1); i++ ) { 125 unsigned char c = wire1[i]; 126 // do something with c 127 if (c == 1){ 128 Serial.print('1'); 129 } 130 else{ 131 Serial.print('0'); 132 } 133} 134*/ 135 136/* 137 for(byte mask = 0x80; mask; mask >>= 1){ 138 if(mask & wire1){ 139 Serial.print('x'); 140 } 141 else{ 142 Serial.print('0'); 143 } 144 Serial.println('.'); 145 }*/ 146 //printBits(wire); 147int done = 0; 148/* 149 for (int index = 0; index < 7; index++) 150 { 151 if (wire1 != oldWire1[index]){ 152 Joystick1.setButton(index, LOW); 153 lastButtonState1[index] = currentButtonState1; 154 } 155 } 156 */ 157 // side buttons 158 Serial.println("Test Wire1:"); 159 Serial.println(wire1, BIN); 160 if ((wire1 & B10000000) == B10000000) {Serial.println("Y");} 161 if ((wire1 & B01000000) == B01000000) {Serial.println("Bl");} 162 if ((wire1 & B00100000) == B00100000) {Serial.println("Wh");} 163 if ((wire1 & B00010000) == B00010000) {Serial.println("Gr");} 164 if ((wire1 & B00001000) == B00001000) {Serial.println("Or");} 165 if ((wire1 & B00000100) == B00000100) {Serial.println("Gy");} 166 if ((wire1 & B00000010) == B00000010) {Serial.println("Br");} 167 if ((wire1 & B00000001) == B00000001) {Serial.println("Rd");} 168 //if (wire1 & B00001010 == B00001010){Joystick1.setButton(0, LOW);};done=1; 169 //if (wire1 & B00001100 == B00000110){Joystick1.setButton(1, LOW);};done=1; 170 //if (wire1 & B00001100 == B00001100){Joystick1.setButton(2, LOW);};done=1; 171 switch(wire1) { 172 case B10000000: Joystick1.setButton(0, LOW); done = 1;break; // X 173 case B10000001: Joystick1.setButton(1, LOW); done = 1;break; // Y 174 case B10000010: Joystick1.setButton(2, LOW); done = 1;break; // Z 175 } 176 // Key pad 177 done = 0; //reset indicator to check key pad 178 switch(wire1){ 179 case B00000001: Joystick1.setButton(3, LOW); done = 1;break; // 1 180 case B00000010: Joystick1.setButton(4, LOW); done = 1;break; // 2 181 case B00000011: Joystick1.setButton(5, LOW); done = 1;break; // 3 182 case B00000100: Joystick1.setButton(6, LOW); done = 1;break; // 4 183 case B00000101: Joystick1.setButton(7, LOW); done = 1;break; // 5 184 case B00000110: Joystick1.setButton(8, LOW); done = 1;break; // 6 185 case B00000111: Joystick1.setButton(9, LOW); done = 1;break; // 7 186 case B00001000: Joystick1.setButton(10, LOW); done = 1;break; // 8 187 case B00001001: Joystick1.setButton(11, LOW); done = 1;break; // 9 188 case B00001010: Joystick1.setButton(12, LOW); done = 1;break; // Clear 189 case B00001011: Joystick1.setButton(13, LOW); done = 1;break; // 0 190 case B00001100: Joystick1.setButton(14, LOW); done = 1;break; // Enter 191 } 192 193 // Disk 194 done = 0; //reset indicator to check Disk 195 switch(wire1){ 196 case B00001101: Joystick1.setButton(15, LOW); done = 1;break; // a 197 case B00001110: Joystick1.setButton(16, LOW); done = 1;break; // b 198 case B00001111: Joystick1.setButton(17, LOW); done = 1;break; // c 199 case B00010000: Joystick1.setButton(18, LOW); done = 1;break; // d 200 case B00010001: Joystick1.setButton(19, LOW); done = 1;break; // e 201 case B00010010: Joystick1.setButton(20, LOW); done = 1;break; // f 202 case B00010011: Joystick1.setButton(21, LOW); done = 1;break; // g 203 case B00010100: Joystick1.setButton(22, LOW); done = 1;break; // h 204 case B00010101: Joystick1.setButton(23, LOW); done = 1;break; // i 205 case B00010110: Joystick1.setButton(24, LOW); done = 1;break; // j 206 case B00010111: Joystick1.setButton(25, LOW); done = 1;break; // k 207 case B00011000: Joystick1.setButton(26, LOW); done = 1;break; // l 208 case B00011001: Joystick1.setButton(27, LOW); done = 1;break; // m 209 case B00011010: Joystick1.setButton(28, LOW); done = 1;break; // n 210 case B00011011: Joystick1.setButton(29, LOW); done = 1;break; // o 211 case B00011100: Joystick1.setButton(30, LOW); done = 1;break; // p 212 } 213 214 215 216} 217
Intellivision-controller.ino
arduino
1#include <Joystick.h> 2/* 3 * This code takes inputs from a 9 pin 4 intellivision controller and converts it into joystick buttons, since all points 5 on disc are just buttons. 6 * Below is an ec=xample of the intellivision ciontroller 7 layout 8 * 9 * +---+---+---+ 10 * X | 1 | 2 | 3 | X 11 * +---+---+---+ 12 13 * Y | 4 | 5 | 6 | Z 14 * +---+---+---+ 15 * | 7 | 8 | 9 | 16 * +---+---+---+ 17 18 * | C | 0 | E | 19 * +---+---+---+ 20 * o p a b c 21 * n 22 \| / d 23 * m - o - e 24 * l / | \ f 25 * k j i h g 26 27 * 28 * Mattel DB9 pinout (intv 2) 29 * ------------- ------------------ 30 31 * \5 4 3 2 1 / \Gr Wh Bl Bk Yl / 32 * \9 8 7 6 / \\ 33 Rd Br Gy Or / 34 * --------- ------------- 35 * 36 * Mattel 37 hardwire pinout (intv 1) 38 * ___________________________________ 39 * 40 | 5 | 4 | 3 | 2 | 1 | 9 | 8 | 7 | 6 | 41 * ----------------------------------- 42 43 * Br | R | O | Y| Gnd | B | Bk| G | W 44 * 45 * Intellivision (DB9) 46 - Arduino (pins) - pin Array position 47 * 1 Yellow - D2 - Yellow 48 - (0) 49 * 2 Black - GND - Black 50 * 3 Blue 51 - D3 - Blue - (1) 52 * 4 White - D4 - White - (2) 53 54 * 5 Green - D5 - Green - (3) 55 * 6 Pink - 56 D6 - Orange - (4) 57 * 7 Grey - D7 - Grey - (5) 58 59 * 8 Brown - D8 - Brown - (6) 60 * 9 Red - 61 D9 - Red - (7) 62 * 63 */ 64 65Joystick_ 66 Joystick1; 67Joystick_ Joystick2; 68// Arduino Micro digital pins 69//int myPin1[8]={5,4,3,2,9,8,7,6}; 70 //Intv1 layout 71int myPin1[8]={2,3,4,5,6,7,8,9}; //Intv 2 layout 72int 73 myPin2[8]={0,0,0,0,0,0,0,0}; 74unsigned char wire1; 75unsigned char wire2; 76unsigned 77 char oldwire1=B11111111; 78unsigned char buttonstate1; 79int ledPin = 13; 80bool 81 ledOn = 0; 82// Last state of buttons 83int lastButtonState1[31] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 84int 85 lastButtonState2[31] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 86 87 88void 89 setup() { 90 // put your setup code here, to run once: 91 // set pin 2-9 as 92 inputy and pull high 93 for (int t=0; t<8; t++) { 94 pinMode ( myPin1[t] , 95 INPUT_PULLUP ); // declare led as output 96 Serial.print(myPin1[t]);Serial.println('.-z.'); 97 98 digitalWrite(ledPin, LOW); // turn off led 99 } 100 Joystick1.begin(); 101 102 Joystick2.begin(); 103 int done = 0; 104} 105 106/* 107 void printBits(byte 108 myByte){ 109 for(byte mask = 0x80; mask; mask >>= 1){ 110 if(mask & myByte) 111 112 Serial.print('1'); 113 else 114 Serial.print('0'); 115 } 116 117 Serial.println('.'); 118 } 119*/ 120void loop() { 121 // put your main code 122 here, to run repeatedly: 123 Serial.print("Test Wire In");Serial.println('.'); 124 125 wire1 = 0; 126 for (int t=0; t<8; t++) { 127 Serial.print(digitalRead(myPin1[t]), 128 DEC);Serial.println(".-."); 129 wire1 |= ((digitalRead(myPin1[t]) == LOW ? 130 1:0)<<(7-t)); 131 } 132 delay(10); 133 Serial.print("Test Wire In");Serial.println('.'); 134 135 //wire1=10000001; // clear wire byte from Controller 1 136 wire2=0; // clear 137 wire byte from Controller 2 138 /* 139 for(byte mask = 0x80; mask; mask >>= 1){ 140 141 if(mask & wire1){ 142 Serial.print('1'); 143 } 144 else{ 145 146 Serial.print('0'); 147 } 148 Serial.println('.'); 149 } 150 */ 151 152 // for(int t=0; t<8; t++){ 153 // wire1 != ((digitalRead(myPin1[t])==LOW ? 0:1)<<(7-t)); 154 // read wire from Controller 1 155 // wire2 != ((digitalRead(myPin2[t])==LOW ? 156 0:1)<<(7-t)); // read wire from Controller 2 157 // } 158 if (wire1 != oldwire1){ 159 160 //Joystick1.releaseAll(); 161 oldwire1 = wire1; 162 ledOn = 1-ledOn; 163 164 digitalWrite(ledPin, ledOn); //turn off led 165 } 166 //currentButtonState1 167 = wire1; 168 //wire1='10000101'; 169/* 170 Serial.print('wire1');Serial.println('.'); 171 172 for(int i =0; i < strlen(wire1); i++ ) { 173 unsigned char c = wire1[i]; 174 175 // do something with c 176 if (c == 1){ 177 Serial.print('1'); 178 } 179 180 else{ 181 Serial.print('0'); 182 } 183} 184*/ 185 186/* 187 for(byte 188 mask = 0x80; mask; mask >>= 1){ 189 if(mask & wire1){ 190 Serial.print('x'); 191 192 } 193 else{ 194 Serial.print('0'); 195 } 196 Serial.println('.'); 197 198 }*/ 199 //printBits(wire); 200int done = 0; 201/* 202 for (int index = 0; index 203 < 7; index++) 204 { 205 if (wire1 != oldWire1[index]){ 206 Joystick1.setButton(index, 207 LOW); 208 lastButtonState1[index] = currentButtonState1; 209 } 210 } 211 212 */ 213 // side buttons 214 Serial.println("Test Wire1:"); 215 Serial.println(wire1, 216 BIN); 217 if ((wire1 & B10000000) == B10000000) {Serial.println("Y");} 218 if 219 ((wire1 & B01000000) == B01000000) {Serial.println("Bl");} 220 if ((wire1 & B00100000) 221 == B00100000) {Serial.println("Wh");} 222 if ((wire1 & B00010000) == B00010000) 223 {Serial.println("Gr");} 224 if ((wire1 & B00001000) == B00001000) {Serial.println("Or");} 225 226 if ((wire1 & B00000100) == B00000100) {Serial.println("Gy");} 227 if ((wire1 228 & B00000010) == B00000010) {Serial.println("Br");} 229 if ((wire1 & B00000001) 230 == B00000001) {Serial.println("Rd");} 231 //if (wire1 & B00001010 == B00001010){Joystick1.setButton(0, 232 LOW);};done=1; 233 //if (wire1 & B00001100 == B00000110){Joystick1.setButton(1, 234 LOW);};done=1; 235 //if (wire1 & B00001100 == B00001100){Joystick1.setButton(2, 236 LOW);};done=1; 237 switch(wire1) { 238 case B10000000: Joystick1.setButton(0, 239 LOW); done = 1;break; // X 240 case B10000001: Joystick1.setButton(1, LOW); done 241 = 1;break; // Y 242 case B10000010: Joystick1.setButton(2, LOW); done = 1;break; 243 // Z 244 } 245 // Key pad 246 done = 0; //reset indicator to check key pad 247 248 switch(wire1){ 249 case B00000001: Joystick1.setButton(3, LOW); done = 1;break; 250 // 1 251 case B00000010: Joystick1.setButton(4, LOW); done = 1;break; // 2 252 253 case B00000011: Joystick1.setButton(5, LOW); done = 1;break; // 3 254 case 255 B00000100: Joystick1.setButton(6, LOW); done = 1;break; // 4 256 case B00000101: 257 Joystick1.setButton(7, LOW); done = 1;break; // 5 258 case B00000110: Joystick1.setButton(8, 259 LOW); done = 1;break; // 6 260 case B00000111: Joystick1.setButton(9, LOW); done 261 = 1;break; // 7 262 case B00001000: Joystick1.setButton(10, LOW); done = 1;break; 263 // 8 264 case B00001001: Joystick1.setButton(11, LOW); done = 1;break; // 9 265 266 case B00001010: Joystick1.setButton(12, LOW); done = 1;break; // Clear 267 case 268 B00001011: Joystick1.setButton(13, LOW); done = 1;break; // 0 269 case B00001100: 270 Joystick1.setButton(14, LOW); done = 1;break; // Enter 271 } 272 273 // Disk 274 275 done = 0; //reset indicator to check Disk 276 switch(wire1){ 277 case B00001101: 278 Joystick1.setButton(15, LOW); done = 1;break; // a 279 case B00001110: Joystick1.setButton(16, 280 LOW); done = 1;break; // b 281 case B00001111: Joystick1.setButton(17, LOW); 282 done = 1;break; // c 283 case B00010000: Joystick1.setButton(18, LOW); done = 284 1;break; // d 285 case B00010001: Joystick1.setButton(19, LOW); done = 1;break; 286 // e 287 case B00010010: Joystick1.setButton(20, LOW); done = 1;break; // f 288 289 case B00010011: Joystick1.setButton(21, LOW); done = 1;break; // g 290 case 291 B00010100: Joystick1.setButton(22, LOW); done = 1;break; // h 292 case B00010101: 293 Joystick1.setButton(23, LOW); done = 1;break; // i 294 case B00010110: Joystick1.setButton(24, 295 LOW); done = 1;break; // j 296 case B00010111: Joystick1.setButton(25, LOW); 297 done = 1;break; // k 298 case B00011000: Joystick1.setButton(26, LOW); done = 299 1;break; // l 300 case B00011001: Joystick1.setButton(27, LOW); done = 1;break; 301 // m 302 case B00011010: Joystick1.setButton(28, LOW); done = 1;break; // n 303 304 case B00011011: Joystick1.setButton(29, LOW); done = 1;break; // o 305 case 306 B00011100: Joystick1.setButton(30, LOW); done = 1;break; // p 307 } 308 309 310 311 312} 313
Comments
Only logged in users can leave comments