请问哪里有Arduino开发ESP32的编程手册-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 5487|回复: 5

请问哪里有Arduino开发ESP32的编程手册

[复制链接]
发表于 2019-1-11 17:03 | 显示全部楼层 |阅读模式
就是用来查看各种API的手册。
比如I/O类有:pinMode();  这个函数
然后Math有:abs();   

还有个问题就是,ESP32有个API,ledcSetup(),ledcWrite()
我查不到这个API的信息
发表于 2019-1-31 13:53 | 显示全部楼层
https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.h
发表于 2019-1-31 14:00 | 显示全部楼层
\Arduinohardware\espressif\esp32\libraries\ESP32\examples\AnalogOut\LEDCSoftwareFade 下的示例 就是LEDC(可编程PWM)的使用示例。
发表于 2019-1-31 14:03 | 显示全部楼层
/*
LEDC Software Fade

This example shows how to software fade LED
using the ledcWrite function.

Code adapted from original Arduino Fade example:
https://www.arduino.cc/en/Tutorial/Fade

This example code is in the public domain.
*/

// use first channel of 16 channels (started from zero)
#define LEDC_CHANNEL_0     0

// use 13 bit precission for LEDC timer
#define LEDC_TIMER_13_BIT  13

// use 5000 Hz as a LEDC base frequency
#define LEDC_BASE_FREQ     5000

// fade LED PIN (replace with LED_BUILTIN constant for built-in LED)
#define LED_PIN            2

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// Arduino like analogWrite
// value has to be between 0 and valueMax
void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) {
  // calculate duty, 8191 from 2 ^ 13 - 1
  uint32_t duty = (8191 / valueMax) * min(value, valueMax);

  // write duty to LEDC
  ledcWrite(channel, duty);
}

void setup() {
  // Setup timer and attach timer to a led pin
  ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_TIMER_13_BIT);
  ledcAttachPin(LED_PIN, LEDC_CHANNEL_0);
}

void loop() {
  // set the brightness on LEDC channel 0
  ledcAnalogWrite(LEDC_CHANNEL_0, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}
发表于 2019-11-5 16:12 | 显示全部楼层

博主  这些函数是什么意思呀  新手不太看得懂呀
发表于 2019-11-5 16:49 | 显示全部楼层
博主 你找到了这个资料了吗
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 04:37 , Processed in 0.096728 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表