Go Down

Topic: Help with CapSense please. (Read 107 times) previous topic - next topic

icey_hood


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 
   Serial.begin(9600);
}

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;
  delay(100);
}


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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy