Components and supplies
Arduino Nano R3
Resistor 10k ohm
Tactile Switch, Top Actuated
CD4066 Quad Bilateral Switch
Tools and machines
Soldering iron (generic)
Solder Wire, Lead Free
Project description
Code
MATRIXIO
arduino
MATRXIO is a program to load the algorithms into the arduino's EEPROM. The Instructions and key coordinates can be sent manually via the arduino IDE serial monitor, or automatically via a loader written in Python.
1#include <EEPROM.h> 2 3int col_map[] = {11, 12, 13, 14, 15, 16, 2 }; //column pins 4int row_map[] = {2, 3, 4, 5, 6, 7, 8, 9, 10 }; //row pins 5int addr = 0; //eeprom address 6int write_mode = 0; 7int instruction_delay = 80; 8 9//sequences: 10 11int sequences[][10] = {{07,01},//avancer de 12{07,11},//tourner de 13{07,21},//s'orienter 14{07,02},//aller x,y 15 16{07,37,01},//stylo crit 17{07,37,11},//stylo relev 18{07,37,21},//mettre var 19{07,37,02},//demander valeur 20 21{07,37,00,37,00,01},//commentaire 22{07,37,00,37,00,11},//afficher rsultat 23{07,37,00,37,00,21},//style 24{07,37,00,37,00,02},//attendre 25 26{07,37,00,37,00,37,00,01},//rpter 27{07,37,00,37,00,37,00,11},//rpter jusqu' 28{07,37,00,37,00,37,00,21},//si alors 29{07,37,00,37,00,37,00,02},//si alors sinon 30 31{07,37,00,37,00,37,00,37,00,01},//excuter 32{07,37,00,37,00,37,00,37,00,11},//copier et insrer 33{07,37,00,37,00,37,00,37,00,21},//insrer ligne 34{07,37,00,37,00,37,00,37,00,02}};//tout supprimer 35 36void setup() { 37 Serial.begin(9600); 38 DDRD = B11111110; 39 DDRB = B111111; 40 DDRC = B00000111; 41 42 //pinMode(A7, INPUT_PULLUP); //add pull-up ressistor 43 //pinMode(A6, INPUT_PULLUP); //add pull-up ressistor 44 pinMode(A5, INPUT_PULLUP); 45 pinMode(A4, INPUT_PULLUP); 46 pinMode(A3, INPUT_PULLUP); 47 Serial.println("MATRIXIO v1.0 (c) Jan 2022 Aditya Chugh -type 'help'-"); 48 Serial.println(""); 49} 50 51void loop() { 52 if (Serial.available() > 0) { 53 String availableString = Serial.readString(); 54 availableString.replace(" ", ""); 55 56 //if (availableString.length() > 3){ 57 58 if (availableString.indexOf("lear") > 0){ 59 Serial.print("Clearing prog "); 60 Serial.print(availableString[5]); 61 Serial.print("..."); 62 int i = (String(availableString[5]).toInt()-1)*200; 63 int f = i + 200; 64 for (i; i < f ; i++) { 65 EEPROM.write(i, 0); 66 } 67 Serial.println("Done."); 68 } 69 70 if (availableString.indexOf("ist") > 0){ 71 int i = (String(availableString[4]).toInt()-1)*200; 72 int f = i + 200; 73 for (i; i < f ; i++) { 74 Serial.print("Address, Instruction: "); 75 Serial.print(i); 76 Serial.print(", "); 77 if (EEPROM.read(i) > 96){ 78 Serial.print(char(EEPROM.read(i))); 79 } else { 80 Serial.print(EEPROM.read(i)); 81 } 82 Serial.println(""); 83 } 84 85 } 86 87 if (availableString.indexOf("rog") > 0){ 88 addr = (String(availableString[4]).toInt() - 1)*200; 89 Serial.print("prog " + String(availableString[4])); 90 Serial.print(" address: "); 91 Serial.println(addr); 92 } 93 94 if (availableString.indexOf("ddr") > 0){ 95 String subString = availableString; 96 subString.remove(0,4); 97 addr = subString.toInt(); 98 Serial.print("Address set to: "); 99 Serial.println(addr); 100 } 101 102 if (availableString.indexOf("rite") > 0){ 103 write_mode = 1; 104 Serial.println("Write mode enabled"); 105 } 106 107 if (availableString.indexOf("ead") > 0){ 108 write_mode = 0; 109 Serial.println("Write mode disabled"); 110 } 111 112 if (availableString.indexOf("elp") > 0){ 113 write_mode = 0; 114 Serial.println(F("Commands:\ 115\ 116xy : Instruction, where x is column and y is row of calculator key\ 117a~t : Shortcut instruction sequences\ 118write : Enable writing of instructions to EEPROM memory\ 119read : Disable enable writing of instructions to EEPROM memory\ 120prog 1~5 : Memory address set to beginning of program 1~5\ 121clear 1~5 : Clears all instructions of program 1~5\ 122list 1~5 : Lists all instructions of program 1~5\ 123addr 0~999 : Memory address set to 0~999 (for uno & nano)\ 124")); 125 Serial.println(F("On Casio FX-92B & FX-92+, the bottom-most row is matrixed differently, keys should be addressed as such:\ 126\ 127'0' : 65\ 128',' : 64\ 129'x10^x' : 63\ 130'ANS/REP' : 62\ 131'EXE' : 61\ 132")); 133 Serial.println(F("Shortcut instruction sequences for Casio FX-92+:\ 134\ 135a : avancer de\ 136b : tourner de\ 137c : s'orienter \ 138d : aller x,y\ 139\ 140e : stylo crit\ 141f : stylo relev\ 142g : mettre var \ 143h : demander valeur\ 144\ 145i : commentaire\ 146j : afficher rsultat\ 147k : style\ 148l : attendre\ 149\ 150m : rpter\ 151n : rpter jusqu'\ 152o : si alors\ 153p : si alors sinon\ 154\ 155q : excuter\ 156r : copier et insrer\ 157s : insrer ligne\ 158t : tout supprimer\ 159")); 160 } 161 162 //} 163 164 if (availableString.length() == 3){ 165 str_to_button_press(availableString); 166 if (write_mode == 1){ 167 str_to_int_to_eeprom(availableString); 168 } 169 } 170 171 if (availableString.length() == 2){ 172 sequence_to_button_press(availableString); 173 if (write_mode == 1){ 174 int i = availableString[0]; 175 str_to_int_to_eeprom(String(i)); 176 } 177 } 178 } 179 /*if (analogRead(A7) == 0) { 180 Serial.println("Program 5"); 181 eeprom_read(800); 182 } 183 if (digitalRead(A6) == LOW) { 184 Serial.println("Program 4"); 185 eeprom_read(600); 186 }*/ 187 if (digitalRead(A5) == LOW) { 188 Serial.println("Program 3"); 189 eeprom_read(400); 190 } 191 if (digitalRead(A4) == LOW) { 192 Serial.println("Program 2"); 193 eeprom_read(200); 194 } 195 if (digitalRead(A3) == LOW) { 196 Serial.println("Program 1"); 197 eeprom_read(0); 198 } 199} 200 201void str_to_button_press(String availableString){ 202 203 int col = String(availableString[0]).toInt(); 204 int row = String(availableString[1]).toInt(); 205 Serial.print ("Address, Instruction: "); 206 Serial.print(addr); 207 Serial.print("," ), 208 Serial.print(col); 209 Serial.print(row); 210 Serial.println(""); 211 digitalWrite(col_map[col], HIGH); 212 digitalWrite(row_map[row], HIGH); 213 delay(instruction_delay); 214 digitalWrite(col_map[col], LOW); 215 digitalWrite(row_map[row], LOW); 216 delay(20); 217 if (availableString == "61"){ 218 delay(500); 219 } 220} 221 222void str_to_int_to_eeprom (String availableString){ 223 EEPROM.write(addr, availableString.toInt()); 224 addr = addr + 1; 225} 226 227void sequence_to_button_press (String availableString){ 228 int sequence = int(availableString[0])-97; 229 Serial.print("Address, Instruction: "); 230 Serial.print(addr); 231 Serial.print("," ), 232 Serial.println(availableString[0]); 233 for (int i = 0 ; i < 10 ; i++){ 234 str_to_button_press(int_to_str(sequences[sequence][i])); 235 } 236} 237 238String int_to_str (int Int){ 239 if (Int > 10){ 240 return String(Int); 241 } else { 242 if (0 < Int < 10){ 243 String subString = "0"; 244 subString += String(Int); 245 return(subString); 246 } 247 } 248} 249 250void eeprom_read(int Start){ 251 int Stop = Start + 200; 252 for (addr = Start; addr < Stop ; addr++) { 253 if (EEPROM.read(addr) > 96){ 254 sequence_to_button_press(String(char(EEPROM.read(addr)))); 255 } else { 256 str_to_button_press(int_to_str(EEPROM.read(addr))); 257 } 258 } 259 addr = 0; 260} 261
Python Algorithm Uploader
python
1import serial 2import time 3 4port = input("COM Port: ") 5arduino = serial.Serial(port=port, baudrate=9600, timeout=1) 6 7filename = input("Filename: ") 8 9lines = [] 10f = open(filename) 11lines = f.readlines() 12 13 14print(arduino.readlines()) 15time.sleep(1) 16arduino.write(bytes(str("write"), 'utf-8')) 17time.sleep(1) 18print(arduino.readlines()) 19arduino.write(bytes(str(str("prog")+input("enter program number 1~5: ")), 'utf-8')) 20time.sleep(1) 21print(arduino.readlines()) 22 23for line in lines: 24 time.sleep(2) 25 receive = arduino.readlines() 26 print(receive) 27 print(line) 28 arduino.write(bytes(str(line), 'utf-8')) 29 30 31 32 33 34
Python Algorithm Uploader
python
1import serial 2import time 3 4port = input("COM Port: ") 5arduino 6 = serial.Serial(port=port, baudrate=9600, timeout=1) 7 8filename = input("Filename: 9 ") 10 11lines = [] 12f = open(filename) 13lines = f.readlines() 14 15 16print(arduino.readlines()) 17time.sleep(1) 18arduino.write(bytes(str("write"), 19 'utf-8')) 20time.sleep(1) 21print(arduino.readlines()) 22arduino.write(bytes(str(str("prog")+input("enter 23 program number 1~5: ")), 'utf-8')) 24time.sleep(1) 25print(arduino.readlines()) 26 27for 28 line in lines: 29 time.sleep(2) 30 receive = arduino.readlines() 31 print(receive) 32 33 print(line) 34 arduino.write(bytes(str(line), 'utf-8')) 35 36 37 38 39 40 41
Downloadable files
CD4066
CD4066
Schematic
(The scheme looks impressive from afar, in reality it is very repetitive)
Schematic
Schematic
(The scheme looks impressive from afar, in reality it is very repetitive)
Schematic
CD4066
CD4066
Comments
Only logged in users can leave comments
kronix_tex
3 years ago
Wow. I hav an FX-92+ for my school, and I use the algorithm mode A LOT. This could be really useful for me. Nice creation!