SODAQ
Connect Anything Anywhere

4. A touch sensor that initiates vibration
In this tutorial 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. This could be applied in the creation of a toy for children such as a robot cat that responds to touch by vibrating.
Required components:
SODAQ Moja
0.5W Solar Panel
1aH battery pack
Grove Touch Sensor
Grove Vibration Motor
2x Grove w/o Buckle Cable (any length)
First, plug the Vibration Motor into the D2/D3 pin in the always on row.
Then, plug the Touch Sensor into the D4/D5 pin in the always on row.
Next, plug the 0.5W solar panel and the 1A LiPo battery into the respective sockets (see http://www.sodaq.net/#!getting-started/c21ma for a board diagram)
Turn on the SODAQ board, compile and upload the following sketch from the arduino IDE onto the SODAQ Board, and then unplug the USB cable from the computer when it is working:
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);
}
}
