Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
nafihahmd
Published © Apache-2.0

Gest-R: A Multi-Purpose No Touch Switch

Gest-R is state of the art gesture switch made to elegantly replace normal electrical switches.

IntermediateFull instructions provided1 hour2,682
Gest-R: A Multi-Purpose No Touch Switch

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
ttp223 touch sensor
×1
Omron Electronic Components LLC G5Q-1-HA DC5 POWER RELAY, SPDT, 5VDC, 10A
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
LED (generic)
LED (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Through Hole Resistor, 300 ohm
Through Hole Resistor, 300 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

circuit diagram

Code

Full code

Arduino
Copy the code and burn into a uC
/*
  Code written by Nafih Ahammed in accordance with Hackster 'Touch Less, Do More' challenge.
  Gest-R is state of art multifunction capacitive Gesture switch.
 */


#define Output 5
bool state1 = false; // State of first capacitive proximity sensor.
bool state2 = false; // State of 2nd capacitive proximity sensor
int GestR = 0; // Gesture 1 implies downward motion and 0 implies uoward motion. 2 means start 'OFF-Timer' and -1 means start 'ON-Timer'.
int t = 5; // determines the delay of timer

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize Pins.
  pinMode(Output, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(2, INPUT);
  pinMode(3, INPUT);

  // Defining Interrupta
  attachInterrupt(digitalPinToInterrupt(2), prox1, RISING);
  attachInterrupt(digitalPinToInterrupt(3), prox2, RISING);
}

// the loop function runs over and over again forever
void loop() {
  switch (GestR){
    case 1:
      digitalWrite(Output, HIGH);
      break;
    case 0:
      digitalWrite(Output, LOW);
      break;
    case 2:
      blinkled();
      digitalWrite(Output, LOW);
      GestR = 0;
      break;
    case -1:
      blinkled();
      digitalWrite(Output, HIGH);
      GestR = 1;
  }
}

void prox1() {
  if (state2) {
    if (GestR == 0)
      GestR = -1;
    else
      GestR = 0;
      
    state2 = false;
  }
  else
    state1 = true;
}

void prox2() {
  if (state1) {
    if (GestR == 1)
      GestR = 2;
    else
      GestR = 1;
      
    state1 = false;
  }
  else
    state2 = true;
}

void blinkled() {
  for (int t = 0; t<5; t++){
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW);
      delay(1000);
    }
}

Credits

nafihahmd

nafihahmd

4 projects β€’ 2 followers

Comments