main.ino 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * This is the Arduino code for an:
  3. * Infrared Obstacle Sensor and displaying the time on 6 digital display and serial monitor.
  4. * Uses preprogrammed distance and converting it into mph.
  5. ***Still needs to count and store laps for average #of laps once button press
  6. ***Still needs to use 2 digit separate display the lap count for the above laps once button press
  7. IR Sensor Wiring:
  8. Brown: 5V DC
  9. Blue: GND
  10. Black: Signal, to PIN 3
  11. Arduino pins to the Large Digit Driver IN
  12. Arduino pin for SPEED DISPLAY
  13. 6 -> CLK (GREEN)
  14. 5 -> LAT (BLUE)
  15. 7 -> SER on the IN side (YELLOW)
  16. 5V -> 5V (ORANGE)
  17. Power Arduino with 12V and connect to Vin -> 12V (RED)
  18. GND -> GND (PURPLE)
  19. 8 -> Push Button
  20. START Input
  21. Arduino pin for LAP DISPLAY
  22. 11 -> CLK (GREEN)
  23. 10 -> LAT (BLUE)
  24. 12 -> SER on the IN side (YELLOW)
  25. 5V -> 5V (ORANGE)
  26. Power Arduino with 12V and connect to Vin -> 12V (RED)
  27. GND -> GND (PURPLE)
  28. */
  29. //GPIO declarations
  30. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. const byte segmentClock = 6;
  32. const byte segmentLatch = 5;
  33. const byte segmentData = 7;
  34. const byte segmentClockLAP = 11;
  35. const byte segmentLatchLAP = 10;
  36. const byte segmentDataLAP = 12;
  37. const byte button = 2;