Created
April 11, 2012 22:01
-
-
Save omsai/2363047 to your computer and use it in GitHub Desktop.
Arduino UNO pulse counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Arduino UNO reads rising edge trigger pulses on pin 2 and displays counter on | |
Sparkfun SerLCD LCD-10097 | |
Photo of setup: http://ompldr.org/vZGNlbA/photo.JPG | |
Pariksheet <p.nanda@andor.com> Mar 2012 | |
*/ | |
#define LCD_REFRESH_INTERVAL_MS 100 | |
/* Pin assignments */ | |
#define INTERRUPT_INPUT 2 | |
int pulse_counter = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
clear_LCD(); | |
// For noise suppression, enable pullup on interrupt pin | |
digitalWrite(INTERRUPT_INPUT, HIGH); | |
attachInterrupt(INTERRUPT_INPUT - 2, | |
interrupt_handler, | |
RISING); | |
} | |
void loop() | |
// Keep LCD blank till a pulse comes in | |
if (pulse_counter > 0) | |
{ | |
clear_LCD(); | |
Serial.println(pulse_counter); | |
delay(LCD_REFRESH_INTERVAL_MS); | |
} | |
} | |
void clear_LCD() | |
{ | |
Serial.write(0xFE); | |
Serial.write(0x01); | |
} | |
void interrupt_handler() | |
{ | |
pulse_counter = pulse_counter + 1; | |
} |
I know this is an old post, but no one has answered escaleraalcielo 's question. Yes, one is missing in front of the "if" statement. Left curly braces must equal right curly braces as the same as with parenthesis.
The URL of Photo of setup is not valid.
Do you have another URL?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After void loop() is there a "{" missing
void loop()
{
// Keep LCD blank till a pulse comes in
if (pulse_counter > 0)
{
clear_LCD();
Serial.println(pulse_counter);
delay(LCD_REFRESH_INTERVAL_MS);
}
}