Bio Sensors

From Randomdata
Jump to: navigation, search

Recently started with some attempts regarding bio-electrical sensors.

After several failed attempts during OHM2013, finally something demonstrable: a heartbeat monitor (Version 1).

This setup measures voltage differences over two electrodes. The first one is wired up between two resistors to ground the system at half voltage relative to the other components, so we can measure voltage differences in both directions. The second electrode is separated from the first with a very high resistor so that it tends to middle voltage as well (and doesn't make the ADC drift).

The Arduino ADC lists the input voltage as a value from 0-1023. Since we want to centre the ground voltage somewhere in the middle, a voltage divider sends the base voltage to 2.5V. In the code, we convert this by subtracting 512 from the sensor reading to get a value around zero. The result is then scaled logarithmically before being sent to a 7-unit led array.

Version 1


int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  for (int i = 2; i <= 8; i++)
    pinMode(i, OUTPUT);

void writebit(int pin, int value, int testbit)
    digitalWrite(pin, (testbit & value) ? HIGH : LOW);

void writebit2(int pin, int value, int testbit)
    digitalWrite(pin, (testbit > value) ? HIGH : LOW);

void loop() {

    sensorValue = analogRead(sensorPin) - 512;
    writebit2(8, sensorValue, -32);
    writebit2(7, sensorValue, -8);
    writebit2(6, sensorValue, -2);
    writebit2(5, sensorValue, 0);
    writebit2(4, sensorValue, 2);
    writebit2(3, sensorValue, 8);
    writebit2(2, sensorValue, 32);