2924 views|5 replies

1452

Posts

1

Resources
The OP
 

[ESP32-Audio-Kit Audio Development Board Review] Basic Use of the Development Board [Copy link]

This post was last edited by jinglixixi on 2021-9-25 10:12

On the ESP32-Audio-Kit audio development board, the most basic peripherals are LED and KEY, and their schematic diagram is shown in Figure 1.

Figure 1 LED and KEY circuit

If KEY5 and KEY6 are used to control LED4 and LED5 respectively, the control procedure is:

int key1Pin = 18;
int key2Pin = 5;
int led1Pin = 22;
int led2Pin = 19;
void setup() {
 pinMode( led1Pin, OUTPUT);
 pinMode( led2Pin, OUTPUT);
 pinMode( key1Pin, INPUT_PULLUP);
 pinMode( key2Pin, INPUT_PULLUP);
}

void loop() {
 if(digitalRead(key1Pin)==0) digitalWrite(led1Pin, LOW);
 else digitalWrite(led1Pin, HIGH);
 if(digitalRead(key2Pin)==0) digitalWrite(led2Pin, LOW);
 else digitalWrite(led2Pin, HIGH);
 delay(1000);
}

What is more interesting is that this circuit also combines the use of analog ports and reads analog signals through pin IO36.

The procedure for implementing analog port signal acquisition is as follows:

int adcPin = 36;
int val = 0;
void setup() {
 Serial.begin(9600);
}

void loop() {
 val=analogRead(adcPin);
 Serial.print("adc:");
 Serial.println(val);
}

After the program is compiled and uploaded, the running result is shown in Figure 2, that is, when the key KEY1 is not pressed, its detection value is 4095, and if KEY1 is pressed, the detection value is zero. It stands to reason that there should be different reactions when other keys are pressed, but strangely, there is no change. This is quite different from the assumption that the key can be identified by the difference in detection value!

Figure 2 Reading the analog port

This post is from RF/Wirelessly

Latest reply

Looking at the schematic, it seems that pressing different buttons should produce different voltages, but it doesn't? Why not test it with a multimeter?   Details Published on 2021-9-26 10:46
 

6555

Posts

0

Resources
2
 

I don't know what the different reactions when pressing the buttons are related to.

Analog port?

This post is from RF/Wirelessly

Comments

In theory, it should form a structure that forms a voltage gradient. Pressing different keys will change the voltage division ratio, so the state of the key can be discovered by the change in voltage.  Details Published on 2021-9-25 10:53
 
 

1452

Posts

1

Resources
3
 
Jacktang posted on 2021-9-25 10:46 Different reactions when buttons are pressed. I don’t know what the analog port has to do with it?

In theory, it should form a structure that forms a voltage gradient. Pressing different keys will change the voltage division ratio, so the state of the key can be analyzed by the change in voltage.

This post is from RF/Wirelessly

Comments

It should be like this  Details Published on 2021-9-25 19:10
 
 
 

6555

Posts

0

Resources
4
 
jinglixixi posted on 2021-9-25 10:53 Jacktang posted on 2021-9-25 10:46 I don't know what the different reactions when pressing the buttons are related to the analog port? It should be constructed...

It should be like this

This post is from RF/Wirelessly
 
 
 

1942

Posts

2

Resources
5
 

Looking at the schematic, it seems that pressing different buttons should produce different voltages, but it doesn't? Why not test it with a multimeter?

This post is from RF/Wirelessly

Comments

That makes sense, I'll go back and look for one.  Details Published on 2021-9-26 16:32
 
 
 

1452

Posts

1

Resources
6
 
w494143467 Published on 2021-9-26 10:46 Looking at the schematic diagram, it seems that pressing different buttons should produce different voltages, but it doesn't work? Use a multimeter to test it.

That makes sense, I'll go back and look for one.

This post is from RF/Wirelessly
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list