Capacative Pressure Sensor

Hi everyone, I'm trying to put together a "pressure sensing pad", my goal for is to detect if I'm still lying in bed sleeping when I should be up.

My pad would consist of two metal plates(foil) with foam in between them, when a weight is applied the foam is compressed and the two plates moves closer to one another. This would change the capacitance right?

What I need is for my Arduino to measure the change in capacitance. Is this possible?

my goal for is to detect if I'm still lying in bed sleeping when I should be up.

I thought that was managed by something called "will power".

Yes, sounds pretty plausible - you could use a capacitive bridge using the sensor and a fixed capacitor of roughly equal value.

join the two capacitors and connect to an analog input. The other lead of each cap goes to a digital pin via a 150ohm resistor, and you feed the digital pins in anti-phase. To centre the analog pin connect it to both GND and 5V via two 10M ohm resistors.

The amplitude and phase of the signal on the analog pin depends on the relative capacitance values. Code something like this might do the job (well I haven't tested this, so a pinch of salt advised):

void  loop ()
{
  digitalWrite (dpin1, LOW) ;
  digitalWrite (dpin2, HIGH) ;
  int difference = analogRead (apin) ;
  digitalWrite (dpin2, LOW) ;
  digitalWrite (dpin1, HIGH) ;
  difference -= analogRead (apin) ;
  if (difference > threshold)
    digitalWrite (outpin, HIGH) ;
  else
    digitalWrite (outpin, LOW) ;
}

dhenry:

my goal for is to detect if I'm still lying in bed sleeping when I should be up.

I thought that was managed by something called "will power".

Yeah not for me, I use two and sometimes three alarm clocks, I sleep through them all on occasion.
This is actually a serious problem for me.