Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile bool rs = false;
- volatile unsigned long ti[4] = {0,0,0,0};
- int _7SEG[] = {B00111111, B00000110, B01011011, B01001111, //0 1 2 3
- B01100110, B01101101, B01111101, B00000111, //4 5 6 7
- B01111111, B01101111, B00000000}; //8 9 /
- void printNum();
- void setup(){
- Serial.begin(9600);
- for(byte i = 0; i <= 1; i++)
- pinMode(18+i, INPUT);
- for(byte i = 0; i <= 19; i++)
- pinMode(22+i, OUTPUT);
- pinMode(2, INPUT);
- attachInterrupt(digitalPinToInterrupt(2), timestamp, CHANGE);
- attachInterrupt(digitalPinToInterrupt(18), rsInt, RISING);
- }
- void loop(){
- if(ti[3]){
- Serial.println(ti[3]);
- }
- }
- void timestamp(){
- volatile byte i = 0;
- while(ti[i] && i <= 3)
- i++;
- if(i <= 3)
- ti[i] = micros();
- }
- void rsInt(){
- ti[0] = 0;
- ti[1] = 0;
- ti[2] = 0;
- ti[3] = 0;
- }
- /*void printNum(unsigned long num){
- for(byte i = 0; i <= 6; i++){
- for(byte j = 0; j <= 7; j++)
- digitalWrite(22+j, bitRead(_7SEG[num%10],j));
- num = num/10;
- digitalWrite(36-i, HIGH);
- delay(1);
- digitalWrite(36-i, LOW);
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment