-/* pin returns 1 when nothing, and 0 when laser is on photodiode */
-#define PHOTO_PIN PINC
-#define PHOTO1_BIT 0
-#define PHOTO2_BIT 1
-#define READ_PHOTOS() (PHOTO_PIN & (_BV(PHOTO1_BIT) | _BV(PHOTO2_BIT)))
-#define READ_PHOTO1() (PHOTO_PIN & _BV(PHOTO1_BIT))
-#define READ_PHOTO2() (PHOTO_PIN & _BV(PHOTO2_BIT))
-
-#define PHOTOS_ALL_OFF (_BV(PHOTO1_BIT) | _BV(PHOTO2_BIT))
-#define PHOTOS_ALL_ON (0)
-#define PHOTOS_1ON_2OFF (_BV(PHOTO2_BIT))
-#define PHOTOS_1OFF_2ON (_BV(PHOTO1_BIT))
-
-
-/* in cycles/64 (unit is 4 us at 16Mhz) */
-#define MAX_PHOTO_TIME ((uint8_t)25) /* t=100us len=5mm rps=40Hz dist=20cm */
-
-#define MIN_INTER_TIME ((uint8_t)12) /* t=50us len=50mm rps=40Hz dist=350cm */
-#define MAX_INTER_TIME ((uint8_t)250) /* t=1000us len=50mm rps=40Hz dist=20cm */
-
-/* in ms */
-#define INTER_LASER_TIME 10
-
-#define NO_MODULATION
-//#define WAIT_LASER
+/* pin returns !0 when nothing, and 0 when laser is on photodiode */
+#define PHOTO_PIN PINB
+#define PHOTO_BIT 0
+#define READ_PHOTO() (!!(PHOTO_PIN & (_BV(PHOTO_BIT))))
+
+/* IR_DELAY **must** be < 32768 */
+#if (defined SPEED_10RPS)
+#define MIN_INTER_TIME ((uint16_t)(160*2)) /* t~=160us dist=350cm */
+#define MAX_INTER_TIME ((uint16_t)(8000*2)) /* t=8ms dist=10cm */
+#define IR_DELAY ((uint16_t)(8000*2))
+#define INTER_LASER_TIME 30 /* in ms */
+#elif (defined SPEED_20RPS)
+#define MIN_INTER_TIME ((uint16_t)(40*16)) /* t~=80us dist=350cm */
+#define MAX_INTER_TIME ((uint16_t)(2000*16)) /* t=2ms dist=? >10cm */
+#define IR_DELAY ((uint16_t)(2000*16))
+#define INTER_LASER_TIME 10 /* in ms */
+#elif (defined SPEED_40RPS)
+#define MIN_INTER_TIME ((uint16_t)(40*16)) /* t~=40us dist=350cm */
+#define MAX_INTER_TIME ((uint16_t)(2000*16)) /* t=2ms dist=10cm */
+#define IR_DELAY ((uint16_t)(2000*16))
+#define INTER_LASER_TIME 10 /* in ms */
+#else
+#error "speed not defined"
+#endif