Arduino Code:

#include <CapacitiveSensor.h>

int breathPin = A0;
int breath = 0;

CapacitiveSensor   cs1 = CapacitiveSensor(4,5);
CapacitiveSensor   cs2 = CapacitiveSensor(4,6);
CapacitiveSensor   cs3 = CapacitiveSensor(4,7);
CapacitiveSensor   cs4 = CapacitiveSensor(4,8);
CapacitiveSensor   cs5 = CapacitiveSensor(4,9);
CapacitiveSensor   cs6 = CapacitiveSensor(4,10);
CapacitiveSensor   cs7 = CapacitiveSensor(4,11);

void setup()
{
   Serial.begin(9600);
}

void loop()
{
    long hole1 =  cs1.capacitiveSensor(30);
    long hole2 =  cs2.capacitiveSensor(30);
    long hole3 =  cs3.capacitiveSensor(30);
    long hole4 =  cs4.capacitiveSensor(30);
    long hole5 =  cs5.capacitiveSensor(30);
    long hole6 =  cs6.capacitiveSensor(30);
    long hole7 =  cs7.capacitiveSensor(30);

    breath = analogRead(breathPin);

    // Print to Serial
    Serial.print(hole1);  Serial.print(",");
    Serial.print(hole2);  Serial.print(",");
    Serial.print(hole3);  Serial.print(",");
    Serial.print(hole4);  Serial.print(",");
    Serial.print(hole5);  Serial.print(",");
    Serial.print(hole6);  Serial.print(",");
    Serial.print(hole7);  Serial.print(",");

    Serial.println(breath);  Serial.print(",");

    delay(50);
}

For interfacing Arduino we will use openFramewroks.

Usefull links

Posted on .
blog comments powered by Disqus