Ollie Smeenk
Published

A touch sensor that initiates vibration

You will learn how to use a touch sensor as well as a vibrating actuator and connect them such that the one action leads to the other.

Full instructions provided1,356
A touch sensor that initiates vibration

Things used in this project

Hardware components

SODAQ Moja
×1
0.5W Solar Panel
×1
1aH battery pack
×1
Grove Touch Sensor
×1
Grove Vibration Motor
×1
Grove w/o Buckle Cable (any length)
×2

Story

Read more

Code

code.c

C/C++
code.c
int MoPin = 2;
  // vibrator Grove connected to digital pin 2
const int TouchPin=4;
  // touch Grove Connected to digital pin 4
 
void setup() {
 pinMode(TouchPin, INPUT);
 pinMode( MoPin, OUTPUT );
}
 
void loop() {
 int sensorValue = digitalRead(TouchPin);
 if(sensorValue==1)
 {
 digitalWrite(MoPin,HIGH);
 }
 else
 {
  digitalWrite(MoPin,LOW);
 }
 
}

Credits

Ollie Smeenk

Ollie Smeenk

8 projects • 6 followers
Business-oriented Tinkerer! Ready to engage in any project for- and not for profit!

Comments