Components and supplies
Male-Header 36 Position 1 Row- Long (0.1")
Resistor 1M ohm
Resistor 330 ohm
Arduino Nano R3
LED (generic)
Project description
Code
CapBoard-Test1-CapSens
c_cpp
How to create a capacitive sensor with CapBoard
1/* 2 Capacitive Sensor Test for CapBoard 3 Turns on and off a LED connected to the port defined by the variable LedPin 4 according to the state of a capacitive sensor connected to the port defined 5 by the variable SensorPin. 6 7 To use this sketch you need to install the CapacitiveSensor library. 8 Follow this link to download the library 9 http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense 10 11 This example code is in the public domain. 12 13 Artis Lab - 2016 14 www.artislab.it 15 info@artislab.it 16 */ 17 18#include <CapacitiveSensor.h> 19boolean isTriggered1=false; 20int Threshold=10000; //Change this value to calibrate the sensor 21//Use the serial monitor to find the value provided by your sensor 22int Samples=30; 23int LedPin=13; 24int SensorPin=2; 25int Emitter=12; 26CapacitiveSensor CapSensor = CapacitiveSensor(Emitter,SensorPin); 27 28 29void setup(){ 30 pinMode(LedPin,OUTPUT); 31 //uncomment the next line if you want to enable the serial communication with the laptop 32 Serial.begin(9600); 33 //CapSensor.set_CS_AutocaL_Millis(10000); 34} 35 36void loop(){ 37 38 long total1=CapSensor.capacitiveSensor(Samples); 39 //uncomment the next line if you want to send the sensor data to the laptop over the serial communication 40 //Comment this line if you want to send the sensor state over the serial with Serial.write!!! 41 Serial.println(total1); 42 if(total1>Threshold) 43 { 44 if(!isTriggered1) 45 { 46 digitalWrite(LedPin,HIGH); 47 //Uncomment the following line to send data over the serial 48 //Serial.write(1); //Sensor State 49 //Serial.write(206); //Sensor ID 50 isTriggered1=true; 51 //Uncomment the following line to print the state of the sensor 52 //Don't use it togheter with Serial.write!!! 53 //Serial.println("CapSens-On"); 54 } 55 } else 56 { 57 if(isTriggered1) 58 { 59 digitalWrite(LedPin,LOW); 60 //Uncomment the following line to send data over the serial 61 //Serial.write(0); //Sensor State 62 //Serial.write(206); //Sensor ID 63 isTriggered1=false; 64 //Uncomment the following line to print the state of the sensor 65 //Don't use it togheter with Serial.write!!! 66 //Serial.println("CapSens-Off"); 67 } 68 } 69} 70
CapBoard Nine Capacitive Sensors
c_cpp
How to create nine capacitive sensors with CapBoard
1#include <CapacitiveSensor.h> 2CapacitiveSensor cs122 = CapacitiveSensor(12,2); 3CapacitiveSensor cs123 = CapacitiveSensor(12,3); 4CapacitiveSensor cs124 = CapacitiveSensor(12,4); 5CapacitiveSensor cs125 = CapacitiveSensor(12,5); 6CapacitiveSensor cs126 = CapacitiveSensor(12,6); 7CapacitiveSensor cs127 = CapacitiveSensor(12,7); 8CapacitiveSensor cs128 = CapacitiveSensor(12,8); 9CapacitiveSensor cs1210 = CapacitiveSensor(12,10); 10CapacitiveSensor cs1211 = CapacitiveSensor(12,11); 11boolean isTriggered1=false; 12boolean isTriggered2=false; 13boolean isTriggered3=false; 14boolean isTriggered4=false; 15boolean isTriggered5=false; 16boolean isTriggered6=false; 17boolean isTriggered7=false; 18boolean isTriggered8=false; 19boolean isTriggered9=false; 20int Soglia=2400; 21int MaxSensorValue=80000; 22int Samples=40; 23int LedPin=13; 24int Filter1=0; 25int Filter2=0; 26int Filter3=0; 27 28 29int i = 0; 30int lastValue0=0; 31void setup(){ 32 pinMode(LedPin,OUTPUT); 33 //cs23.set_CS_AutocaL_Millis(0xFFFFFFFF); 34 Serial.begin(115200); 35 //Serial.begin(9600); 36 cs122.set_CS_AutocaL_Millis(20000); 37 cs123.set_CS_AutocaL_Millis(20000); 38 cs124.set_CS_AutocaL_Millis(20000); 39 cs125.set_CS_AutocaL_Millis(20000); 40 cs126.set_CS_AutocaL_Millis(20000); 41 cs127.set_CS_AutocaL_Millis(20000); 42 cs128.set_CS_AutocaL_Millis(20000); 43 cs1210.set_CS_AutocaL_Millis(20000); 44 cs1211.set_CS_AutocaL_Millis(20000); 45} 46 47void loop(){ 48 49 long total1=cs122.capacitiveSensor(Samples); 50 //Serial.println(total1); 51 if(total1>Soglia){ 52 int value1=constrain(map(total1,Soglia,MaxSensorValue,200,0),0,200); 53 //Filter1=0.8*Filter1+0.2*value1; 54 byte data1=byte(value1); 55 56 57 Serial.write(data1); 58 Serial.write(201); 59 60 delayMicroseconds(500); 61 } 62 else{ 63 Serial.write(0); 64 Serial.write(201); 65 delayMicroseconds(500); 66 67 } 68 69 70 long total2=cs123.capacitiveSensor(Samples); 71 if(total2>Soglia){ 72 int value2=constrain(map(total2,Soglia,MaxSensorValue,200,0),0,200); 73 //Filter2=0.8*Filter2+0.2*value2; 74 byte data2=byte(value2); 75 76 77 Serial.write(data2); 78 Serial.write(202); 79 80 delayMicroseconds(500); 81 } 82 else{ 83 Serial.write(0); 84 Serial.write(202); 85 delayMicroseconds(500); 86 87 } 88 89 long total3=cs124.capacitiveSensor(Samples); 90 if(total3>Soglia){ 91 int value3=constrain(map(total3,Soglia,MaxSensorValue,200,0),0,200); 92 //Filter3=0.8*Filter3+0.2*value3; 93 byte data3=byte(value3); 94 95 96 Serial.write(data3); 97 Serial.write(203); 98 99 delayMicroseconds(500); 100 } 101 else{ 102 Serial.write(0); 103 Serial.write(203); 104 delayMicroseconds(500); 105 106 } 107 108 long total4=cs125.capacitiveSensor(Samples); 109 if(total4>Soglia){ 110 int value4=constrain(map(total4,Soglia,MaxSensorValue,200,0),0,200); 111 byte data4=byte(value4); 112 113 Serial.write(data4); 114 Serial.write(204); 115 116 delayMicroseconds(500); 117 } 118 else{ 119 Serial.write(0); 120 Serial.write(204); 121 delayMicroseconds(500); 122 123 } 124 125 long total5=cs126.capacitiveSensor(Samples); 126 if(total5>Soglia){ 127 int value5=constrain(map(total5,Soglia,MaxSensorValue,200,0),0,200); 128 byte data5=byte(value5); 129 130 Serial.write(data5); 131 Serial.write(205); 132 133 delayMicroseconds(500); 134 } 135 else{ 136 Serial.write(0); 137 Serial.write(205); 138 delayMicroseconds(500); 139 140 } 141 142 long total6=cs127.capacitiveSensor(Samples); 143 if(total6>Soglia){ 144 int value6=constrain(map(total6,Soglia,MaxSensorValue,200,0),0,200); 145 byte data6=byte(value6); 146 147 Serial.write(data6); 148 Serial.write(206); 149 150 delayMicroseconds(500); 151 } 152 else{ 153 Serial.write(0); 154 Serial.write(206); 155 delayMicroseconds(500); 156 157 } 158 159 long total7=cs128.capacitiveSensor(Samples); 160 if(total7>Soglia){ 161 int value7=constrain(map(total7,Soglia,MaxSensorValue,200,0),0,200); 162 byte data7=byte(value7); 163 164 Serial.write(data7); 165 Serial.write(207); 166 167 delayMicroseconds(500); 168 } 169 else{ 170 Serial.write(0); 171 Serial.write(207); 172 delayMicroseconds(500); 173 174 } 175 176 long total8=cs1210.capacitiveSensor(Samples); 177 if(total8>Soglia){ 178 int value8=constrain(map(total8,Soglia,MaxSensorValue,200,0),0,200); 179 byte data8=byte(value8); 180 181 Serial.write(data8); 182 Serial.write(208); 183 184 delayMicroseconds(500); 185 } 186 else{ 187 Serial.write(0); 188 Serial.write(208); 189 delayMicroseconds(500); 190 191 } 192 193 long total9=cs1211.capacitiveSensor(Samples); 194 if(total9>Soglia){ 195 int value9=constrain(map(total9,Soglia,MaxSensorValue,200,0),0,200); 196 byte data9=byte(value9); 197 198 Serial.write(data9); 199 Serial.write(209); 200 201 delayMicroseconds(500); 202 } 203 else{ 204 Serial.write(0); 205 Serial.write(209); 206 delayMicroseconds(500); 207 208 } 209} 210
CapBoard Nine Capacitive Sensors
c_cpp
How to create nine capacitive sensors with CapBoard
1#include <CapacitiveSensor.h> 2CapacitiveSensor cs122 = CapacitiveSensor(12,2); 3CapacitiveSensor cs123 = CapacitiveSensor(12,3); 4CapacitiveSensor cs124 = CapacitiveSensor(12,4); 5CapacitiveSensor cs125 = CapacitiveSensor(12,5); 6CapacitiveSensor cs126 = CapacitiveSensor(12,6); 7CapacitiveSensor cs127 = CapacitiveSensor(12,7); 8CapacitiveSensor cs128 = CapacitiveSensor(12,8); 9CapacitiveSensor cs1210 = CapacitiveSensor(12,10); 10CapacitiveSensor cs1211 = CapacitiveSensor(12,11); 11boolean isTriggered1=false; 12boolean isTriggered2=false; 13boolean isTriggered3=false; 14boolean isTriggered4=false; 15boolean isTriggered5=false; 16boolean isTriggered6=false; 17boolean isTriggered7=false; 18boolean isTriggered8=false; 19boolean isTriggered9=false; 20int Soglia=2400; 21int MaxSensorValue=80000; 22int Samples=40; 23int LedPin=13; 24int Filter1=0; 25int Filter2=0; 26int Filter3=0; 27 28 29int i = 0; 30int lastValue0=0; 31void setup(){ 32 pinMode(LedPin,OUTPUT); 33 //cs23.set_CS_AutocaL_Millis(0xFFFFFFFF); 34 Serial.begin(115200); 35 //Serial.begin(9600); 36 cs122.set_CS_AutocaL_Millis(20000); 37 cs123.set_CS_AutocaL_Millis(20000); 38 cs124.set_CS_AutocaL_Millis(20000); 39 cs125.set_CS_AutocaL_Millis(20000); 40 cs126.set_CS_AutocaL_Millis(20000); 41 cs127.set_CS_AutocaL_Millis(20000); 42 cs128.set_CS_AutocaL_Millis(20000); 43 cs1210.set_CS_AutocaL_Millis(20000); 44 cs1211.set_CS_AutocaL_Millis(20000); 45} 46 47void loop(){ 48 49 long total1=cs122.capacitiveSensor(Samples); 50 //Serial.println(total1); 51 if(total1>Soglia){ 52 int value1=constrain(map(total1,Soglia,MaxSensorValue,200,0),0,200); 53 //Filter1=0.8*Filter1+0.2*value1; 54 byte data1=byte(value1); 55 56 57 Serial.write(data1); 58 Serial.write(201); 59 60 delayMicroseconds(500); 61 } 62 else{ 63 Serial.write(0); 64 Serial.write(201); 65 delayMicroseconds(500); 66 67 } 68 69 70 long total2=cs123.capacitiveSensor(Samples); 71 if(total2>Soglia){ 72 int value2=constrain(map(total2,Soglia,MaxSensorValue,200,0),0,200); 73 //Filter2=0.8*Filter2+0.2*value2; 74 byte data2=byte(value2); 75 76 77 Serial.write(data2); 78 Serial.write(202); 79 80 delayMicroseconds(500); 81 } 82 else{ 83 Serial.write(0); 84 Serial.write(202); 85 delayMicroseconds(500); 86 87 } 88 89 long total3=cs124.capacitiveSensor(Samples); 90 if(total3>Soglia){ 91 int value3=constrain(map(total3,Soglia,MaxSensorValue,200,0),0,200); 92 //Filter3=0.8*Filter3+0.2*value3; 93 byte data3=byte(value3); 94 95 96 Serial.write(data3); 97 Serial.write(203); 98 99 delayMicroseconds(500); 100 } 101 else{ 102 Serial.write(0); 103 Serial.write(203); 104 delayMicroseconds(500); 105 106 } 107 108 long total4=cs125.capacitiveSensor(Samples); 109 if(total4>Soglia){ 110 int value4=constrain(map(total4,Soglia,MaxSensorValue,200,0),0,200); 111 byte data4=byte(value4); 112 113 Serial.write(data4); 114 Serial.write(204); 115 116 delayMicroseconds(500); 117 } 118 else{ 119 Serial.write(0); 120 Serial.write(204); 121 delayMicroseconds(500); 122 123 } 124 125 long total5=cs126.capacitiveSensor(Samples); 126 if(total5>Soglia){ 127 int value5=constrain(map(total5,Soglia,MaxSensorValue,200,0),0,200); 128 byte data5=byte(value5); 129 130 Serial.write(data5); 131 Serial.write(205); 132 133 delayMicroseconds(500); 134 } 135 else{ 136 Serial.write(0); 137 Serial.write(205); 138 delayMicroseconds(500); 139 140 } 141 142 long total6=cs127.capacitiveSensor(Samples); 143 if(total6>Soglia){ 144 int value6=constrain(map(total6,Soglia,MaxSensorValue,200,0),0,200); 145 byte data6=byte(value6); 146 147 Serial.write(data6); 148 Serial.write(206); 149 150 delayMicroseconds(500); 151 } 152 else{ 153 Serial.write(0); 154 Serial.write(206); 155 delayMicroseconds(500); 156 157 } 158 159 long total7=cs128.capacitiveSensor(Samples); 160 if(total7>Soglia){ 161 int value7=constrain(map(total7,Soglia,MaxSensorValue,200,0),0,200); 162 byte data7=byte(value7); 163 164 Serial.write(data7); 165 Serial.write(207); 166 167 delayMicroseconds(500); 168 } 169 else{ 170 Serial.write(0); 171 Serial.write(207); 172 delayMicroseconds(500); 173 174 } 175 176 long total8=cs1210.capacitiveSensor(Samples); 177 if(total8>Soglia){ 178 int value8=constrain(map(total8,Soglia,MaxSensorValue,200,0),0,200); 179 byte data8=byte(value8); 180 181 Serial.write(data8); 182 Serial.write(208); 183 184 delayMicroseconds(500); 185 } 186 else{ 187 Serial.write(0); 188 Serial.write(208); 189 delayMicroseconds(500); 190 191 } 192 193 long total9=cs1211.capacitiveSensor(Samples); 194 if(total9>Soglia){ 195 int value9=constrain(map(total9,Soglia,MaxSensorValue,200,0),0,200); 196 byte data9=byte(value9); 197 198 Serial.write(data9); 199 Serial.write(209); 200 201 delayMicroseconds(500); 202 } 203 else{ 204 Serial.write(0); 205 Serial.write(209); 206 delayMicroseconds(500); 207 208 } 209} 210
CapBoard-Test1-CapSens
c_cpp
How to create a capacitive sensor with CapBoard
1/* 2 Capacitive Sensor Test for CapBoard 3 Turns on and off a LED connected to the port defined by the variable LedPin 4 according to the state of a capacitive sensor connected to the port defined 5 by the variable SensorPin. 6 7 To use this sketch you need to install the CapacitiveSensor library. 8 Follow this link to download the library 9 http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense 10 11 This example code is in the public domain. 12 13 Artis Lab - 2016 14 www.artislab.it 15 info@artislab.it 16 */ 17 18#include <CapacitiveSensor.h> 19boolean isTriggered1=false; 20int Threshold=10000; //Change this value to calibrate the sensor 21//Use the serial monitor to find the value provided by your sensor 22int Samples=30; 23int LedPin=13; 24int SensorPin=2; 25int Emitter=12; 26CapacitiveSensor CapSensor = CapacitiveSensor(Emitter,SensorPin); 27 28 29void setup(){ 30 pinMode(LedPin,OUTPUT); 31 //uncomment the next line if you want to enable the serial communication with the laptop 32 Serial.begin(9600); 33 //CapSensor.set_CS_AutocaL_Millis(10000); 34} 35 36void loop(){ 37 38 long total1=CapSensor.capacitiveSensor(Samples); 39 //uncomment the next line if you want to send the sensor data to the laptop over the serial communication 40 //Comment this line if you want to send the sensor state over the serial with Serial.write!!! 41 Serial.println(total1); 42 if(total1>Threshold) 43 { 44 if(!isTriggered1) 45 { 46 digitalWrite(LedPin,HIGH); 47 //Uncomment the following line to send data over the serial 48 //Serial.write(1); //Sensor State 49 //Serial.write(206); //Sensor ID 50 isTriggered1=true; 51 //Uncomment the following line to print the state of the sensor 52 //Don't use it togheter with Serial.write!!! 53 //Serial.println("CapSens-On"); 54 } 55 } else 56 { 57 if(isTriggered1) 58 { 59 digitalWrite(LedPin,LOW); 60 //Uncomment the following line to send data over the serial 61 //Serial.write(0); //Sensor State 62 //Serial.write(206); //Sensor ID 63 isTriggered1=false; 64 //Uncomment the following line to print the state of the sensor 65 //Don't use it togheter with Serial.write!!! 66 //Serial.println("CapSens-Off"); 67 } 68 } 69} 70
Downloadable files
CapBoard Pcb
CapBoard Pcb Layout
CapBoard Pcb
CapBoard Schematic
Connection schematic for CapBoard
CapBoard Schematic
CapBoard Pcb
CapBoard Pcb Layout
CapBoard Pcb
Comments
Only logged in users can leave comments
costantinorizzuti
2 years ago
Thanks!!! Tuff is a kind of sedimentary rock. In Matera is the most used building material so we used blocks of tuff to create capacitive sensors
costantinorizzuti
0 Followers
•2 Projects
1
2
CapBoard | Arduino Project Hub
Anonymous user
7 years ago
cool what are tuff blocks?