Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. // Import the CapacitiveSensor Library.
  2. #include <CapacitiveSensor.h>
  3.  
  4.  
  5. // Name the pin as led.
  6. #define speaker 11
  7.  
  8.  
  9. // Set the Send Pin & Receive Pin.
  10. CapacitiveSensor cs_2_3 = CapacitiveSensor(2,3); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
  11. CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
  12. CapacitiveSensor cs_2_5 = CapacitiveSensor(2,5); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  13. CapacitiveSensor cs_2_6 = CapacitiveSensor(2,6); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  14. CapacitiveSensor cs_2_7 = CapacitiveSensor(2,7); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  15. CapacitiveSensor cs_2_8 = CapacitiveSensor(2,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  16. CapacitiveSensor cs_2_9 = CapacitiveSensor(2,9); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  17.  
  18.  
  19. void setup()
  20. {
  21. cs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
  22.  
  23. // Arduino start communicate with computer.
  24. Serial.begin(9600);
  25. }
  26.  
  27. void loop()
  28. {
  29. // Set a timer.
  30. long start = millis();
  31.  
  32. // Set the sensitivity of the sensors.
  33. long total1 = cs_2_3.capacitiveSensor(60);
  34. long total2 = cs_2_4.capacitiveSensor(60);
  35. long total3 = cs_2_5.capacitiveSensor(60);
  36. /* long total4 = cs_2_6.capacitiveSensor(60);
  37. long total5 = cs_2_7.capacitiveSensor(60);
  38. long total6 = cs_2_8.capacitiveSensor(60);
  39. long total7 = cs_2_9.capacitiveSensor(60);*/
  40.  
  41.  
  42.  
  43. Serial.print(millis() - start); // check on performance in milliseconds
  44. Serial.print("t"); // tab character for debug windown spacing
  45.  
  46. Serial.print(total1); // print sensor output 1
  47. Serial.print("t"); // Leave some space before print the next output
  48. Serial.print(total2); // print sensor output 2
  49. Serial.print("t"); // Leave some space before print the next output
  50. Serial.print(total3); // print sensor output 3
  51. Serial.print("t"); // Leave some space before print the next output
  52. Serial.print("n");
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement