I’m using an Arduino Due to count and send out pulses. The sending out pulses are suppose to last for 1000 microseconds. How do I keep counting the incoming pulses at the same time?
Here is the code:
int encoderCount = 0;
boolean sampledPin;
boolean lastVal=0;
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
pinMode(22,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
I’m using an Arduino Due to count and send out pulses. The sending out pulses are suppose to last for 1000 microseconds. How do I keep counting the incoming pulses at the same time?
Here is the code:
int encoderCount = 0;
boolean sampledPin;
boolean lastVal=0;
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
pinMode(22,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
JarvisSong:
I'm using an Arduino Due to count and send out pulses. The sending out pulses are suppose to last for 1000 microseconds. How do I keep counting the incoming pulses at the same time?
This is confusing.
You say you are sending out pulses and then you say you want to count incoming pulses. Which are you doing - sending or receiving?
The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
What is the application?
Are you counting pulses from an external source and want to gate them ON for a particular number of pulses or time.
OR
Are you producing the pulses in the DUE and gating them ON for a particular number of pulses or time.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?