Great, thanks! I'll mention it.
--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include <PinChangeInt.h>
#define PIN_ANEMOMETER 8 // Digital 8 for Anemometer (Wind speed) - uses PinChangeInt library
#define PIN_RAINGAUGE 9 // Digital 9 for rain bucket - uses Pin ChangeInt library
void setup() {
Serial.begin(9600);
pinMode(PIN_ANEMOMETER, INPUT_PULLUP); // input from wind meters windspeed sensor
pinMode(PIN_RAINGAUGE, INPUT_PULLUP); // input from wind meters rain gauge sensor
digitalWrite(PIN_ANEMOMETER, HIGH);
digitalWrite(PIN_RAINGAUGE, HIGH);
PCintPort::attachInterrupt(PIN_ANEMOMETER, countAnemometer, FALLING);
PCintPort::attachInterrupt(PIN_RAINGAUGE, countRainGauge, FALLING);
}
//=======================================================
// Interrupt handler for anemometer. Called each time the
// reed switch triggers (one revolution).
//=======================================================
void countAnemometer() {
Serial.print("Anemometer Interrupt");
}
//=======================================================
// Interrupt handler for rain gauge. Called each time the
// reed switch triggers (one bucket tip).
//=======================================================
void countRainGauge() {
Serial.print("Rain Interrupt");
}--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include <PinChangeInt.h>
// 1. any pin can interrupt expect pin 12
// 2. pin 10 resets counter
// 4. pin 12 is beeper
#define PIN_INTERRUPTA0 A0
#define PIN_INTERRUPTA1 A1
#define PIN_INTERRUPTA2 A2
#define PIN_INTERRUPTA3 A3
#define PIN_INTERRUPTA4 A4
#define PIN_INTERRUPTA5 A5
#define PIN_INTERRUPT0 0
#define PIN_INTERRUPT1 1
#define PIN_INTERRUPT2 2
#define PIN_INTERRUPT3 3
#define PIN_INTERRUPT4 4
#define PIN_INTERRUPT5 5
#define PIN_INTERRUPT6 6
#define PIN_INTERRUPT7 7
#define PIN_INTERRUPT8 8
#define PIN_INTERRUPT9 9
#define PIN_INTERRUPT10 10
#define PIN_INTERRUPT11 11 // for reset
//#define PIN_INTERRUPT12 12 // used for beeper or led
#define PIN_INTERRUPT13 13
#define PIN_PIEZO 12 // for piezo or led
//OK pins 8, 9, 10, 11
// not OK pins 12, 13
volatile uint16_t nbInterrupts=0;
void setup() {
Serial.begin(9600);
// ANALOG PINS
pinMode(PIN_INTERRUPTA0, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA0, HIGH);
pinMode(PIN_INTERRUPTA1, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA1, HIGH);
pinMode(PIN_INTERRUPTA2, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA2, HIGH);
pinMode(PIN_INTERRUPTA3, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA3, HIGH);
pinMode(PIN_INTERRUPTA4, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA4, HIGH);
pinMode(PIN_INTERRUPTA5, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPTA5, HIGH);
PCintPort::attachInterrupt(PIN_INTERRUPTA0, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPTA1, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPTA2, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPTA3, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPTA4, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPTA5, countInterrupts, FALLING);
// DIGITAL PINS
pinMode(PIN_INTERRUPT0, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT0, HIGH);
pinMode(PIN_INTERRUPT1, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT1, HIGH);
pinMode(PIN_INTERRUPT2, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT2, HIGH);
pinMode(PIN_INTERRUPT3, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT3, HIGH);
pinMode(PIN_INTERRUPT4, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT4, HIGH);
pinMode(PIN_INTERRUPT5, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT5, HIGH);
pinMode(PIN_INTERRUPT6, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT6, HIGH);
pinMode(PIN_INTERRUPT7, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT7, HIGH);
pinMode(PIN_INTERRUPT8, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT8, HIGH);
pinMode(PIN_INTERRUPT9, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT9, HIGH);
pinMode(PIN_INTERRUPT10, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT10, HIGH);
pinMode(PIN_INTERRUPT11, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT11, HIGH);
pinMode(PIN_INTERRUPT13, INPUT_PULLUP);
digitalWrite(PIN_INTERRUPT13, HIGH);
PCintPort::attachInterrupt(PIN_INTERRUPT0, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT1, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT2, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT3, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT4, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT5, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT6, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT7, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT8, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT9, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT10, countInterrupts, FALLING);
PCintPort::attachInterrupt(PIN_INTERRUPT11, resetInterrupts, FALLING); // reset
PCintPort::attachInterrupt(PIN_INTERRUPT13, countInterrupts, FALLING);
beep(50,250);
}
void loop() {
for( int a = 0; a < nbInterrupts; a = a + 1 ) {
beep(50,250);
}
delay(5000);
beep(500,250);
}
//=======================================================
// Sound or led
//=======================================================
void beep(unsigned char delayms, unsigned int freq){
analogWrite(PIN_PIEZO, freq); // Almost any value can be used except 0 and 255
// experiment to get the best tone
delay(delayms); // wait for a delayms ms
analogWrite(PIN_PIEZO, 0); // 0 turns it off
delay(delayms); // wait for a delayms ms
}
//=======================================================
// Interrupt handler for anemometer. Called each time the
// reed switch triggers (one revolution).
//=======================================================
void countInterrupts() {
nbInterrupts++;
}
void resetInterrupts() {
nbInterrupts=0;
}
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint-discuss+unsub...@googlegroups.com.
---Mike Schwager
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint-discuss+unsub...@googlegroups.com.
---Mike Schwager
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.