Author Options:

Can you Please Help with Arduino Code? Answered

I was wondering if you could help me with the code i have. Its basic and my knowledge of coding if very limited.
Im upgrading my fume extractor and in the spirit of keeping up with the 21st century, i want to dump the old throw switch and implement capSense. The code i have works brilliant with but its for 1 switch but i need 2 and don't know how to do it
this is the code(read below code for more):

#include <CapSense.h>

// 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, foil
CapSense   cs_4_2 = CapSense(4,2);       

const int ledPin1 = 13;

void setup()                
   cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example  

void loop() {
  static boolean lastSensorHit = false;
  static boolean LEDvalue = LOW;

  bool sensorHit = cs_4_2.capSense(30) > 1100;

  if (sensorHit && !lastSensorHit)  // Now true, was false
    LEDvalue = !LEDvalue; // Toggle the LED
    digitalWrite(ledPin1, LEDvalue);
  lastSensorHit = sensorHit;

What I'd like to do is, have 1st capSense give out 2 outputs say 2 Led's and stay on just like in the code and the 2nd capSense move a servo 45 degrees delay .5 second then give out 1 output i.e an  Led aand stay on, just like capsense 1.

Thank you in advance everyone.


The forums are retiring in 2021 and are now closed for new topics and comments.