esp32_gpio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
esp32_gpio [2023/02/27 08:03] – created 192.168.1.66esp32_gpio [2023/02/27 14:04] (current) 192.168.1.66
Line 1: Line 1:
-To set a pin as output, you must disable the modes "Interrupt" "pull Up" and "pull Down", which would be rather input modes. You must configure the mode as "output mode" and you must specify which pins these changes affect using pin_bit_mask\\+Arduino code:
  
-<code> +  * pinMode(GPIO, OUTPUT);\\ 
-gpio_config_t io_conf; +  * digitalWrite(GPIO, STATE);\\
-    io_conf.intr_type = GPIO_PIN_INTR_DISABLE;//disable interrupt +
-    io_conf.mode = GPIO_MODE_OUTPUT;//set as output mode +
-    io_conf.pin_bit_mask = (1ULL<<18);//bit mask of the pins that you want to set,e.g.GPIO18 +
-    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;//disable pull-down mode +
-    io_conf.pull_up_en = GPIO_PULLUP_DISABLE;//disable pull-up mode +
-    esp_err_t error=gpio_config(&io_conf);//configure GPIO with the given settings +
-    if(error!=ESP_OK){ +
-        printf("error configuring outputs \n"); +
-    } +
-</code>+
  
-To set a pin as inputYou must put the mode io_conf.mode )as input and select if you want the low level to be interpreted as active or inactive using pull_down_en\\+  * pinMode(GPIOINPUT);\\ 
 +  * digitalRead(GPIO);\\
  
-<code> 
-io_conf.intr_type = GPIO_PIN_INTR_DISABLE;//disable interrupt 
-io_conf.mode = GPIO_MODE_INPUT;//set as inputmode 
-io_conf.pin_bit_mask = (1ULL<<15);//bit mask of the pins that you want to set,e.g.GPIO15 
-io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;//enable pull-down mode 
-io_conf.pull_up_en = GPIO_PULLUP_DISABLE;//disable pull-up mode 
-esp_err_t error=gpio_config(&io_conf);//configure GPIO with the given settings 
- 
-if(error!=ESP_OK){ 
-    printf("error configuring inputs\n"); 
-} 
-</code> 
  
 +The following modes are supported for the basic input and output:\\
  
 +  * INPUT sets the GPIO as input without pullup or pulldown (high impedance).
 +  * OUTPUT sets the GPIO as output/read mode.
 +  * INPUT_PULLDOWN sets the GPIO as input with the internal pulldown.
 +  * INPUT_PULLUP sets the GPIO as input with the internal pullup.
esp32_gpio.1677502982.txt.gz · Last modified: 2023/02/27 08:03 by 192.168.1.66