Capacitive Switch Panel
Here i will go through the project with the switchpanel.
A description of the project:
This will be an Arduino based project with the Arduino Uno R3 as base, to that ill hook up a MPR121 and this 8 Channel Relay Module. The goal is to have the touch sensitive swithces to trigger the relays that will replace the original rocker swithces in the boat, and this will be buildt in a sleek aluminium plate with a black plexiglass front.
Aaannd… The panel is done:)
I finally got the new MPR121 i ordered and spent the whole day on finishing, lots of time went on final touches and grinding on the aluminium frame to get the plexi glass to fit just right. now all i have to do is mount it in the boat:), well i might have to clean up the kitchen to..
i took the case of an old adsl modem that fitted just perfect for the electronics and for the power for the arduino i took a cigarette usb car charger and i can still access the usb on the arduino easy on the back of the case if i want to make some adjustments in the code:)
Mounted the leds.
Backside of being old, my eyes is not what they once were:/
So close to finish now, just weaiting for the white flat top leds and hopefully ill get a new mpr121 to soon so i could end this project:)
Got the decals today, well i think i got some more then i needed, but if anyone is interested of follow this build let me know and ill might have one over for you:), it has a nice texture in the material and looks really nice.
Was at the boat today and did a test mount, think this is going to be really good, unfortunatly i dropped the panel on the ground so there was some ugly marks in it so back to the bench and polish it again:(
The frame and plexiglassfront is finished, phew.. that was a lot of grinding and polishing:) I have also ordered the stickers thats going on the plexi and will get those in a couple of days. but what is a project without some failures, something happened with the mpr121 card when i resoldered and is not working anymore:( so ill just have to order another one, but they was of course out of stock so i guess im gonna have to wait some for that, hopefully ill get it at the same time i get my white flat top led´s that was shipped from China some days ago:)
The code for it all is also finished (Thanks to Glenn at my work) so i now have everything set and got a nice feature to it to, the switch for the motor compartment fan has on/off state but also automatic switch of after 1 minute
Progress going forward, i have started creating the panel and that is a lot of work, processing 4mm aluminum isnt easy, but with some curses and hard work its doable:)
I also found some more code for the actual relayboard and got that working to, i think i also got some understanding of how to put all code togheter so im hoping to get that done in a couple of days:) and ofc some images:)
And this is kind of how it will look when finished.
Halfway, now its time to mill the front of the panel for the plexiglass (that will be fun.. or not)
This is what i started with, got this for free at the recycling company that i have just around the corner:) its 4mm aluminum.
I have soldered tha cards togheter now and as the image of the schematics show below this i how i hooked it up.
So far i have managed to get signal from the mpr121 via the arduino to my pc and the terminalwindow with this code: Taken from BILDR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
#include "mpr121.h" #include <Wire.h> int irqpin = 2; // Digital 2 boolean touchStates[12]; //to keep track of the previous touch states void setup(){ pinMode(irqpin, INPUT); digitalWrite(irqpin, HIGH); //enable pullup resistor Serial.begin(9600); Wire.begin(); mpr121_setup(); } void loop(){ readTouchInputs(); } void readTouchInputs(){ if(!checkInterrupt()){ //read the touch state from the MPR121 Wire.requestFrom(0x5A,2); byte LSB = Wire.read(); byte MSB = Wire.read(); uint16_t touched = ((MSB << 8) | LSB); //16bits that make up the touch states for (int i=0; i < 12; i++){ // Check what electrodes were pressed if(touched & (1<<i)){ if(touchStates[i] == 0){ //pin i was just touched Serial.print("pin "); Serial.print(i); Serial.println(" was just touched"); }else if(touchStates[i] == 1){ //pin i is still being touched } touchStates[i] = 1; }else{ if(touchStates[i] == 1){ Serial.print("pin "); Serial.print(i); Serial.println(" is no longer being touched"); //pin i is no longer being touched } touchStates[i] = 0; } } } } void mpr121_setup(void){ set_register(0x5A, ELE_CFG, 0x00); // Section A - Controls filtering when data is > baseline. set_register(0x5A, MHD_R, 0x01); set_register(0x5A, NHD_R, 0x01); set_register(0x5A, NCL_R, 0x00); set_register(0x5A, FDL_R, 0x00); // Section B - Controls filtering when data is < baseline. set_register(0x5A, MHD_F, 0x01); set_register(0x5A, NHD_F, 0x01); set_register(0x5A, NCL_F, 0xFF); set_register(0x5A, FDL_F, 0x02); // Section C - Sets touch and release thresholds for each electrode set_register(0x5A, ELE0_T, TOU_THRESH); set_register(0x5A, ELE0_R, REL_THRESH); set_register(0x5A, ELE1_T, TOU_THRESH); set_register(0x5A, ELE1_R, REL_THRESH); set_register(0x5A, ELE2_T, TOU_THRESH); set_register(0x5A, ELE2_R, REL_THRESH); set_register(0x5A, ELE3_T, TOU_THRESH); set_register(0x5A, ELE3_R, REL_THRESH); set_register(0x5A, ELE4_T, TOU_THRESH); set_register(0x5A, ELE4_R, REL_THRESH); set_register(0x5A, ELE5_T, TOU_THRESH); set_register(0x5A, ELE5_R, REL_THRESH); set_register(0x5A, ELE6_T, TOU_THRESH); set_register(0x5A, ELE6_R, REL_THRESH); set_register(0x5A, ELE7_T, TOU_THRESH); set_register(0x5A, ELE7_R, REL_THRESH); set_register(0x5A, ELE8_T, TOU_THRESH); set_register(0x5A, ELE8_R, REL_THRESH); set_register(0x5A, ELE9_T, TOU_THRESH); set_register(0x5A, ELE9_R, REL_THRESH); set_register(0x5A, ELE10_T, TOU_THRESH); set_register(0x5A, ELE10_R, REL_THRESH); set_register(0x5A, ELE11_T, TOU_THRESH); set_register(0x5A, ELE11_R, REL_THRESH); // Section D // Set the Filter Configuration // Set ESI2 set_register(0x5A, FIL_CFG, 0x04); // Section E // Electrode Configuration // Set ELE_CFG to 0x00 to return to standby mode set_register(0x5A, ELE_CFG, 0x0C); // Enables all 12 Electrodes // Section F // Enable Auto Config and auto Reconfig /*set_register(0x5A, ATO_CFG0, 0x0B); set_register(0x5A, ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V set_register(0x5A, ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V set_register(0x5A, ATO_CFGT, 0xB5);*/ // Target = 0.9*USL = 0xB5 @3.3V set_register(0x5A, ELE_CFG, 0x0C); } boolean checkInterrupt(void){ return digitalRead(irqpin); } void set_register(int address, unsigned char r, unsigned char v){ Wire.beginTransmission(address); Wire.write(r); Wire.write(v); Wire.endTransmission(); } |
So, and next step will be to implement the relayboard and get some code working for that to.
These are the components i have for it atm (theres also a little board for the 12v to the USB to drive the Arduino)
And a template for the panel
And this is what i will look like when finished.
Taylor Hill
Awesome project, can I ask who made your labels or what they are made out of?
Artifaction
Thanks, The layout i made myself then i got it to a local print service company and they printed it out on vinyl sheets.
Bman
Hi! What an impressive project!
BTW, what software did you use to draw you mokeup (last picture) ?
Artifaction
I use autodesk Maya when i do mockups in 3D
Vince27
Very nice work.
I was wondering: where are the LED connected to ?
Artifaction
they are just connected to the relay switches as a status indicator.