Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define IR_PIN 3
- #define TIME 3000
- long nextUpdateTime = 0;
- int collisionsCount = 0;
- int irValue = 0;
- int setup()
- {
- Serial.begin(9600);
- pinMode(IR_PIN, INPUT);
- nextUpdateTime = millis() + TIME;
- }
- int loop()
- {
- if (nextUpdateTime >= millis())
- {
- Serial.print("Pocet preruseni: ");
- Serial.println(collisionsCount);
- collisionsCount = 0;
- nextUpdateTime = millis() + TIME;
- }
- else
- {
- irValue = digitalRead(IR_PIN);
- if(irValue == HIGH)
- {
- collisionsCount++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement