Skip to content

Commit

Permalink
added tachometer example
Browse files Browse the repository at this point in the history
  • Loading branch information
neu-rah committed Sep 7, 2017
1 parent 04dc87b commit c6d9812
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
.clang_complete
.gcc-flags.json
.piolibdeps
*.gch
*.gch
lib
.travis.yml
!/.travis.yml
platformio.ini
4 changes: 4 additions & 0 deletions examples/tachometer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
31 changes: 31 additions & 0 deletions examples/tachometer/tachometer/tachometer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//simple tachometer sending data to serial port
//it only prints rpm's of the last measure

#include <pcint.h>

#define SensorPin 2

volatile unsigned long t=0;
volatile unsigned long ot=0;
unsigned int rpm=0;

void tick() {
ot=t;
t=millis();
}

void setup() {
Serial.begin(9600);
while(!Serial);
pinMode(SensorPin,INPUT_PULLUP);
PCattachInterrupt<SensorPin>(tick,RISING);
}

void loop() {
if((millis()-t)>300) rpm=0;
else if (t!=ot) rpm=60000.0/(float)(t-ot);
Serial.print(rpm);
Serial.print(" ");
Serial.println(t-ot);
delay(100);
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=PCINT r-site.net
version=4.0.3
version=4.0.4
author=Rui Azevedo, ruihfazevedo@gmail.com
maintainer=neu-rah, ruihfazevedo@gmail.com
sentence=Arduino Pin change monitor
paragraph=Attach user function and data to pin change events.
category=Uncategorized
category=Signal Input
dot_a_linkage=true
url=https://github.com/neu-rah/PCINT
architectures=*
Expand Down

0 comments on commit c6d9812

Please # to comment.