IFD:PhysicalComp2011/code: Difference between revisions

From Medien Wiki
(Solution for exercise IV added)
(Added capacitive sensing (Arduino))
Line 1,036: Line 1,036:
     curPos = 0;
     curPos = 0;
   }
   }
}
</source>
<br /> <br />
== 12.12.2011 Arduino & Processing sketches ==
=== V Capacitive Sensing (Arduino) ===
[[File:V_arduino_capacitive_sensing.png|200px|thumb]]
<source lang="java">
/* CAPACITVE SENSING (ARDUINO)
*
* Example of how to include external libraries.
* In this case we are using the CapSense Library
* (http://www.arduino.cc/playground/Main/CapSense)
* to turn a piece of aluminium foil into a capacitive
* sensor. Check out the description page for more
* details and options.
* Frederic Gmeiner, 2011
*/
#include <CapSense.h>
CapSense  cs_9_2 = CapSense(9,2);       
long capValue;
void setup()                   
{
  Serial.begin(9600);
}
void loop()                   
{
  capValue =  cs_9_2.capSense(30);
  Serial.println(capValue);       
  delay(10);                       
}
}
</source>
</source>