-->
Page 1 of 2

ArduinoIDE: Hardware PWM: example to dim LED on the ESP-01?

PostPosted: Wed Jan 20, 2016 12:56 pm
by vanderbreye
Is there a way to implement a hardware PWM on the ESP-01 on any of the GPIOs?
I've seen some software timers, but i need a better performance..
I try to dim a LED-panel via transistor on one of GPIO-0/1/2, but i have ABSOLUTELY no ideas how to implement something like this via the IDE... :oops:

Re: ArduinoIDE: Hardware PWM: example to dim LED on the ESP-

PostPosted: Wed Jan 20, 2016 3:48 pm
by jankop
Here is primitive demo sketch for GPIO2. It is tested with LED. Anode to Vcc with resistor, katode to GPIO2.


Code: Select allvoid setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
 for (int i=0; i < 1024; i++){
      analogWrite(2, i);
      delay(1);
   }
   for (int i=1023; i > 0; i--){
      analogWrite(2, i);
      delay(1);
   }
}

Re: ArduinoIDE: Hardware PWM: example to dim LED on the ESP-

PostPosted: Wed Jan 20, 2016 3:49 pm
by WereCatf

Re: ArduinoIDE: Hardware PWM: example to dim LED on the ESP-

PostPosted: Thu Jan 21, 2016 6:24 am
by vanderbreye
Yeah, thank you for both answers, thats right, it would work...
But: Both solutions are softwarePWMs, which are using delays...

I THOUGHT i read about a hardwarePWM pin on the ESP-01...
http://tech.scargill.net/esp8266-pwm-on-one-output/ ?!
Sadly, I have no clue how to implement this via GPIO2 (or any other GPIO?) on the ESP-01...

if its possible to do it in the IOT_sdk, shouldn't it be possible in the Arduino as well?