Generate microSecond pulse

Try commenting out the printing, reducing the delays, and then measure the results.


I have this code. i am getting Data like that


#define LED 16           // Led in NodeMCU at pin GPIO16 (D0).
void setup() {
  pinMode(LED, OUTPUT);    // LED pin as output.
  Serial.begin(115200);
}
void loop() {
  digitalWrite(LED, HIGH);// turn the LED off.(Note that LOW is the voltage level but actually
  //the LED is on; this is because it is acive low on the ESP8266.
  delayMicroseconds(3);            // wait for 1 second.
 // Serial.println("High");
  digitalWrite(LED, LOW); // turn the LED on.
 // Serial.println("LOW");
  delayMicroseconds(3);
  
}

If it is too long, shorten the delays. It takes time to digitalWrite, delay, and to loop, so you may not need the full delayMicroseconds(3);

My requirement is to generate 3us On time and 3us off time.
what can i do?

I have Arduino Uno and NodeMCU unit. Best way to get above requirement code and sample code

This is one way of speeding up the pin toggling on the ESP8266/nodemcu by direct port manipulation: Direct GPIO port register manipulation - Everything ESP8266

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.