Hey Guys,
For a Project I am using a Arduino Uno, with a Capacitive Sensor. I want it so that when the sensor is touched the motor will go on for a curtain time, and then go off again, until the sensor is touched again.
I have a working code for the capacitive Sensor, that also gives a reading. But I don't know how to add the motor into the code correctly, can someone please help me?
#include <CapacitiveSensor.h>
/*
* Uses a high value resistor of 10M ohm between send pin and receive pin
* change with the Capacitive Sensor will trigger a small vibration motor
*/
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
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()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.print(total1); // print sensor output 1
Serial.print("\t");
delay(10); // arbitrary delay to limit data to serial port
}