int ledPin = 2; // select the input pin for the potentiometer int i=0; void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); digitalWrite(ledPin,LOW); } void loop() { on(2250); //(40khz modulated) off(27600); //(no signal) on(650us); off(1375); on(575); off(3350); on(650); digitalWrite(ledPin,LOW); delay(63); //-- repeated a second time after 63ms on(2250); //(40khz modulated) off(27600); //(no signal) on(650us); off(1375); on(575); off(3350) on(650) } void on(int time){ digitalWrite(ledPin,HIGH); //period of a 40kHz modulated signal is 1/40000 = 25 microseconds //divide the time do be on for by 25 then iterate through that amount with it on for 13 and off for 12 micro at a time until you hit the time/25 } void off(int time){ digitalWrite(ledPin,LOW); delayMicroseconds(time); }