Hallo everyone!
I am new wuth arduino and i have some questions about it, so i hope somebody can help.
I have to make a series of very fast sensors, where the state can change from 0 to 1 and back to 0
within 5 miliseconds.
Can Arduino see this fast changes on an digital input?
If yes, what about of the sum of 16 digital inputs that can change the states so fast?
Example: The 16 digital inputs have this state: 0000000011111111
than the states change to: 0000111111111111
and after about 5 miliseconds back to: 0000000011111111
If this change happens within 5 miliseconds than set an output,
else if this change takes more than 5 miliseconds do nothing.
Something like this, read the 3 ports, move into position in an int, then do it again until it changes
byte dPins = PIND; // D7-D0 use bits 7-2, keep 1-0 free for serial
unsigned int bPins = PINB; // D13-D8 use bits 5-0
insigned int cPins = PINC; // D19-D14 use bits 5-0
// move into position
unsigned int sixteenPins = cPins << 10 | (bPins <<6) | (dPins >>2);
while (sixteenPins == newSixteen){ // keep reading until different
byte dPins = PIND; // D7-D0 use bits 7-2, keep 1-0 free for serial
unsigned int bPins = PINB; // D13-D8 use bits 5-0
unsigned int cPins = PINC; // D19-D14 use bits 5-0
unsigned int newSixteen = cPins << 10 | (bPins <<6) | (dPins >>2);
// jump out when it changes
}
Serial.print ("Got a change ");
Serial.print (sixteenPins, HEX);
Serial.print (" new ");
Serial.println (newSixteen, HEX);
First, thanks for the answers.
How to implement this code CrossRoads, to say, if it change happens then look if it turns back
within 5 miliseconds? With delay it cant, because the program stops for this time and doesnt look
for changes.