Hi, Tom.
I will try 74HC148 as well.
Thanks for helping me and showing me the datasheet.
I really appreciate it.
Yosuke
ESP32 with a tons of switch
Re: ESP32 with a tons of switch
Hello, ESP_Sprite.
I appreciate you giving me the advice.
Unfortunately, the result was the same.
I'm trying to use universal board right now because I don't have an oscilloscope and logic analyzer. Sometimes, I will rent these measuring machines.
I used diodes(one diode per one button) to avoid Phantom key and be able to press multiple buttons at the same time.
Here is the circuit with 48 buttons(6 rows × 8 columns). And here is a piece of schematic. this circuit worked in the expected way.
I could build key matrix circuit by Arduino UNO 3,
so I assumed that If I divert that circuit and use the similar codes, it would be easier to build the key matrix circuit by ESP32.
What I thought was wrong. haha
Thanks, Yosuke.
I appreciate you giving me the advice.
Following your advice, I've tried to add an external resistor(12K) from that pin to 3.3V.ESP_Sprite wrote:Yosuke: I'm not quite sure why you get the results you do... the only thing that springs to mind immediately is that your breadboard setup has a fairly big parasitic capacitance, and the pull-up in GPIO16 may not be enough to overpower it. You can try adding an external resistor (anywhere between 1K and 10K should work) from that pin to 3.3V. If that doesn't work: if you have an oscilloscope or logic analyzer, it may be helpful to visualize the signals and see what's happening.
Unfortunately, the result was the same.
I'm trying to use universal board right now because I don't have an oscilloscope and logic analyzer. Sometimes, I will rent these measuring machines.
When I built the key matrix circuit by Arduino UNO 3 two years ago,ESP_Sprite wrote:(Yosuke: you may still want to modify your schematic a little bit. If you press two buttons at the same time, you're essentially shorting your selected low output with an unselected, high output at times. This is Not Good in general. You could work around this by e.g. connecting 1K resistors between the buttons and the '138; that's enough to limit the current, but will still easily over-power the internal pull-up, which is 50K or so. Even better: use diodes instead of resistors so current can only run from the buttons into the '138; that way your setup can actually detect all the buttons pressed as well.)
I used diodes(one diode per one button) to avoid Phantom key and be able to press multiple buttons at the same time.
Here is the circuit with 48 buttons(6 rows × 8 columns). And here is a piece of schematic. this circuit worked in the expected way.
I could build key matrix circuit by Arduino UNO 3,
so I assumed that If I divert that circuit and use the similar codes, it would be easier to build the key matrix circuit by ESP32.
What I thought was wrong. haha
Thanks, Yosuke.
Re: ESP32 with a tons of switch
Yosuke,
In the diagram above it appears that the 138 is being used for 2 output purposes: 1) to send a polling signal to each of the 8 columns (of 2 switches) and combined with led0/1 to light 1 of the 16 leds (8 columns 2 rows).
The switch values are presented to the long connector which chooses what row of switches and what column and through the 138 which led row and column. The 138 is used as output only and is being used correctly
The process is polling which returns column switch values to the long connector no to the 138.
For your purpose a 148 is the correct part and is easily chained or matrixed to read more switches.
Tom Meyers
In the diagram above it appears that the 138 is being used for 2 output purposes: 1) to send a polling signal to each of the 8 columns (of 2 switches) and combined with led0/1 to light 1 of the 16 leds (8 columns 2 rows).
The switch values are presented to the long connector which chooses what row of switches and what column and through the 138 which led row and column. The 138 is used as output only and is being used correctly
The process is polling which returns column switch values to the long connector no to the 138.
For your purpose a 148 is the correct part and is easily chained or matrixed to read more switches.
Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic
Santiago, Dominican Republic
Re: ESP32 with a tons of switch
Don't give-up.
1) use 148 to read 7 switches
2) See below for reading more
Reading More:
Take a look here: https://www.embeddedrelated.com/showarticle/519.php
For more than 8 buttons you can use a matrix and easily get to 64 buttons.
HC138 for polling rows (0..8) while reading from am HC148 columns.
for 148 value =0; < 8; ++
Read 138 value (it gives 0..7 or none)
pretty easy, Tom Meyers
1) use 148 to read 7 switches
2) See below for reading more
Reading More:
Take a look here: https://www.embeddedrelated.com/showarticle/519.php
For more than 8 buttons you can use a matrix and easily get to 64 buttons.
HC138 for polling rows (0..8) while reading from am HC148 columns.
for 148 value =0; < 8; ++
Read 138 value (it gives 0..7 or none)
pretty easy, Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic
Santiago, Dominican Republic
Re: ESP32 with a tons of switch
To Tom Meyers,
Thank you for your advice.
I do appreciate it.
I ordered 74HC148 yesterday and I will receive it tomorrow.
So, I'll try to verify that 74HC148 with ESP32 works correctly.
Maybe, as is the case with 74HC138, 74HC148 used with ESP32 doesn't work correctly.
To all,
I used universal board because breadboard might cause that defect.
And I used my code(Version 1), but the result was the same.
When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 1 or 3. ←wrong
When I pressed #4 switch, I got 6. ←wrong
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 0. ←wrong
When I pressed #7 switch, I got 7. ←right This defect happens under any circumstances.
On the other hand, if I change the wirings appropriately, it is no longer a problem except #3 switch.
I noticed another interesting thing.
I tried ESP32-DevKitC(made by Espressif Systems) in the same circuit and same code(version 1). The result is following.
When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 0. ←wrong
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right
#0 switch and #4 switch have replaced each other.
This defect depends on developer kit!
Here is a comparison of developer kit.
ESPr® Developer 32(made by SWITCH SCIENCE)................ESP32-DevKitC(made by Espressif Systems)
When I pressed #0 switch, I got 4. ←wrong.............When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right.......................When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right.......................When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 1 or 3. ←wrong.......When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 6. ←wrong.............When I pressed #4 switch, I got 0. ←wrong
When I pressed #5 switch, I got 5. ←right.......................When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 0. ←wrong.............When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right.......................When I pressed #7 switch, I got 7. ←right
I changed the wirings appropriately(#0 switch → PIN 4 of HC138 and #4 switch → PIN 0 of HC138).
When I pressed #0 switch, I got 0. ←right
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 4. ←right
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right
All right! Yeah
Thank you for your advice.
I do appreciate it.
I ordered 74HC148 yesterday and I will receive it tomorrow.
So, I'll try to verify that 74HC148 with ESP32 works correctly.
Maybe, as is the case with 74HC138, 74HC148 used with ESP32 doesn't work correctly.
To all,
I used universal board because breadboard might cause that defect.
And I used my code(Version 1), but the result was the same.
When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 1 or 3. ←wrong
When I pressed #4 switch, I got 6. ←wrong
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 0. ←wrong
When I pressed #7 switch, I got 7. ←right This defect happens under any circumstances.
On the other hand, if I change the wirings appropriately, it is no longer a problem except #3 switch.
I noticed another interesting thing.
I tried ESP32-DevKitC(made by Espressif Systems) in the same circuit and same code(version 1). The result is following.
When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 0. ←wrong
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right
#0 switch and #4 switch have replaced each other.
This defect depends on developer kit!
Here is a comparison of developer kit.
ESPr® Developer 32(made by SWITCH SCIENCE)................ESP32-DevKitC(made by Espressif Systems)
When I pressed #0 switch, I got 4. ←wrong.............When I pressed #0 switch, I got 4. ←wrong
When I pressed #1 switch, I got 1. ←right.......................When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right.......................When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 1 or 3. ←wrong.......When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 6. ←wrong.............When I pressed #4 switch, I got 0. ←wrong
When I pressed #5 switch, I got 5. ←right.......................When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 0. ←wrong.............When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right.......................When I pressed #7 switch, I got 7. ←right
I changed the wirings appropriately(#0 switch → PIN 4 of HC138 and #4 switch → PIN 0 of HC138).
When I pressed #0 switch, I got 0. ←right
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 3. ←right
When I pressed #4 switch, I got 4. ←right
When I pressed #5 switch, I got 5. ←right
When I pressed #6 switch, I got 6. ←right
When I pressed #7 switch, I got 7. ←right
All right! Yeah
Re: ESP32 with a tons of switch
I added diodes(one diode per one button) to my circuit, but I can't press multiple buttons at the same time.
hmm...
hmm...
Re: ESP32 with a tons of switch
I recieved 74HC148 and I tried to verify it with ESP32, 7 switches, and 7 resisters(12K).
The result was not what was expected. Here is my codes.
The result was;
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 2 or 3. ←wrong
When I pressed #4 switch, I got 4. ←right
When I pressed #5 switch, I got 4 or 5. ←wrong
When I pressed #6 switch, I got 4 or 6. ←wrong
When I pressed #7 switch, I got 4 or 6 or 7. ←wrong
The result was not what was expected. Here is my codes.
Code: Select all
void setup() {
pinMode(12, INPUT);
pinMode(13, INPUT);
pinMode(14, INPUT);
Serial.begin(115200);
}
void loop() {
byte res1 = (GPIO.in >> 12) & 0x1;
byte res2 = (GPIO.in >> 13) & 0x1;
byte res3 = (GPIO.in >> 14) & 0x1;
if(res1&&res2&&res3){return;}
else if(!res1&&res2&&res3) {Serial.println("Pressed button1");delay(100);}
else if(res1&&!res2&&res3) {Serial.println("Pressed button2");delay(100);}
else if(!res1&&!res2&&res3) {Serial.println("Pressed button3");delay(100);}
else if(res1&&res2&&!res3) {Serial.println("Pressed button4");delay(100);}
else if(!res1&&res2&&!res3) {Serial.println("Pressed button5");delay(100);}
else if(res1&&!res2&&!res3) {Serial.println("Pressed button6");delay(100);}
else if(!res1&&!res2&&!res3) {Serial.println("Pressed button7");delay(100);}//*/
}
When I pressed #1 switch, I got 1. ←right
When I pressed #2 switch, I got 2. ←right
When I pressed #3 switch, I got 2 or 3. ←wrong
When I pressed #4 switch, I got 4. ←right
When I pressed #5 switch, I got 4 or 5. ←wrong
When I pressed #6 switch, I got 4 or 6. ←wrong
When I pressed #7 switch, I got 4 or 6 or 7. ←wrong
Who is online
Users browsing this forum: jesper and 95 guests