const int outPin = 8; // digital pin 8 #define rpm_to_us(rpm) (1000000UL / (rpm / 60)) void setup() { Serial.begin(115200UL); //シリアル通信開始 Serial.print("Begin\n"); pinMode(outPin, OUTPUT); digitalWrite(outPin, HIGH); } void loop() { digitalWrite(outPin, LOW); delayMicroseconds(100); digitalWrite(outPin, HIGH); delayMicroseconds(rpm_to_us(20000) - 100); }