
Modular Programmable gear shifter
Description
Building it will need a bit of coding experience. I will release my code, but there is practically no way it will work perfectly on others, as it needs calibration based on how many gears it has and what potentiometers it is using. These are the potentiometers I used: Ungodly long link: https://www.ebay.com/itm/224194967103?hash=item34330fb63f:g:JosAAOSwumNfh-6a&amdata=enc%3AAQAHAAAA4BnBp3BUqOSDtgO%2BOkIjRKj0v9FFKMXXQ9uqokanQnO7wLzAVmPI4UIP5jxfqxlrH6xW4AZqCVRTBvgK8pOYLXPH1yx%2BCQVkT%2FIhBRpeCP4Urcb%2BZvO2niOBFan45Zdas26XnpDSzteuZqou72Z4vWUyEMWQ1LN3btBMW5JmgdjqVHnnZcc3RNfQqD0VIRjhNuHjZD0mp%2B9olAukn%2BT%2F%2FnFRfpvaXT9RP7y8KDF9esnFZFwq%2BEfXHtrvlWpHU29srmHNCGK9jgIm97mgBadqyWju3nn22%2FY54qx8XUR8IykY%7Ctkp%3ABFBMsvKc5Z9h I used the Pro Trinket 5V for the coding. My code will turn gears 1-6 into binary and pressing the buttons 1-3 on your keyboard as binary numbers. Here is the code I'm running on it: #include "ProTrinketKeyboard.h" void setup() { pinMode(A2, INPUT); pinMode(A4,INPUT); TrinketKeyboard.begin(); } int T1=640; int T2=480; int T3=300; int track; int updown; int gear; int accuracy=50; int down=350; int up=650; int updownR; int trackR; void loop() { getReading(); getTrack(); getUpDown(); getGear(); TurnBin(); } void getReading(){ updownR=analogRead(A4); trackR=analogRead(A2); } void getTrack(){ if(trackR <= T1+accuracy && trackR >= T1-accuracy){ track=1; }else if(trackR <= T2+accuracy && trackR >= T2-accuracy){ track=2; }else if(trackR <= T3+accuracy && trackR >= T3-accuracy){ track=3; }else{ track=0; } } void getUpDown(){ if(updownR <= up+accuracy && updownR >= up-accuracy){ updown=1; }else if(updownR <= down+accuracy && updownR >= down-accuracy){ updown=2; }else{ updown=0; } } void getGear(){ if(track==1 && updown==1){ gear=1; }else if(track==1 && updown==2){ gear=2; }else if(track==2 && updown==1){ gear=3; }else if(track==2 && updown==2){ gear=4; }else if(track==3 && updown==1){ gear=5; }else if(track==3 && updown==2){ gear=6; }else{ gear=0; } } //Allows serial print with the trinket, definitions 1-3 are what it prints (0 to print nothing), 4 is the delay in ms*5, and the 5th is the spacing between each print. //You have to open a writing program quickly after running this. void numprint(int p1034,int p2034,int p3034,int d034, int enter034){ if(p1034 != 0){ TrinketKeyboard.print(p1034); TrinketKeyboard.pressKey(0, KEYCODE_ENTER); TrinketKeyboard.pressKey(0,0); } if(p2034 != 0){ TrinketKeyboard.print(p2034); TrinketKeyboard.pressKey(0, KEYCODE_ENTER); TrinketKeyboard.pressKey(0,0); } if(p3034 != 0){ TrinketKeyboard.print(p3034); TrinketKeyboard.pressKey(0, KEYCODE_ENTER); TrinketKeyboard.pressKey(0,0); } for(int wait034=0; wait034<d034; wait034++){ TrinketKeyboard.poll(); delay(5); } for(int wait034=0; wait034<enter034; wait034++){ TrinketKeyboard.pressKey(0, KEYCODE_ENTER); TrinketKeyboard.pressKey(0,0); } TrinketKeyboard.poll(); } void TurnBin(){ if(gear==0){ TrinketKeyboard.pressKey(0, 0); } if(gear==1){ TrinketKeyboard.pressKey(0, KEYCODE_1); } if(gear==2){ TrinketKeyboard.pressKey(0, KEYCODE_2); } if(gear==3){ TrinketKeyboard.pressKey(0, KEYCODE_1,KEYCODE_2); } if(gear==4){ TrinketKeyboard.pressKey(0, KEYCODE_3); } if(gear==5){ TrinketKeyboard.pressKey(0, KEYCODE_1,KEYCODE_3); } if(gear==6){ TrinketKeyboard.pressKey(0, KEYCODE_2,KEYCODE_3); } }
Statistics
Likes
0
Downloads
0