Good day, This is a very basic question but...
I need to get either a 1 or 0 from 3 buttons but I haven't found an easy / simple way to do it. Most clash with the wifi / bl. Any ideas of what should be used for this ?
Thanks
Simplest way to get readings from a button ?
-
- Posts: 74
- Joined: Fri Dec 04, 2020 4:23 pm
Re: Simplest way to get readings from a button ?
(1)Please post the pin numbers and (2) the circuit.
(3) How will you handle bounce?
(4)Maybe a code snip too
Tom
(3) How will you handle bounce?
(4)Maybe a code snip too
Tom
IT Professional, Maker
Santiago, Dominican Republic
Santiago, Dominican Republic
-
- Posts: 74
- Joined: Fri Dec 04, 2020 4:23 pm
Re: Simplest way to get readings from a button ?
Here is my code:
And here is how I got it conected:
https://cdn-learn.adafruit.com/assets/a ... 1472798079
Code: Select all
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include <driver/adc.h>
#include "esp_adc_cal.h"
void app_main(){
while(1){
uint32_t reading = adc1_get_raw(ADC1_CHANNEL_5);
printf("\n reading = %d ",reading);
vTaskDelay(250 / portTICK_PERIOD_MS);
}}
https://cdn-learn.adafruit.com/assets/a ... 1472798079
Re: Simplest way to get readings from a button ?
https://learn.adafruit.com/micropython- ... tal-inputs
1) i recommend a pull-up on that pin or enable internal pullup: that way it is high or low
2) you will experience bounce and i think you will need to debounce the value
Take a look at what adafruit has written for more.
That pin is not involved with wifi but others are see: https://docs.espressif.com/projects/esp ... s/adc.html
Tom
1) i recommend a pull-up on that pin or enable internal pullup: that way it is high or low
2) you will experience bounce and i think you will need to debounce the value
Take a look at what adafruit has written for more.
That pin is not involved with wifi but others are see: https://docs.espressif.com/projects/esp ... s/adc.html
Tom
IT Professional, Maker
Santiago, Dominican Republic
Santiago, Dominican Republic
Who is online
Users browsing this forum: atx823, MicroController and 147 guests