codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
//Causes Arduino.h to be disabled when compiling from Arduino IDE #define Skip_Arduino #ifdef Skip_Arduino #define Arduino_h /* Arduino.h is always automaticaly included if omited, but if we include * it manualy after Arduino_h is defined it will be disabled. */ #include <Arduino.h> #endif #include <stdint.h> #include <avr/io.h> #include "IOBitAccess.h" #define SNSK B2 #define SNS B3 int main() { while (true) { //discharge reference and sense capacitors DDR(SNSK) = 1; DDR(SNS) = 1; __builtin_avr_delay_cycles(20); while (PIN(SNSK) == 0) { //disconnect reference capacitor DDR(SNS) = 0; //charge sense capacitor, then disconnect PORT(SNSK) = 1; DDR(SNSK) = 1; __builtin_avr_delay_cycles(20); DDR(SNSK) = 0; PORT(SNSK) = 0; //allow current to flow from sense to reference capacitor DDR(SNS) = 1; __builtin_avr_delay_cycles(20); } } }
Private
[
?
]
Run code
Submit