some problem esp8266
dcjona opened this issue · comments
Hi,
i tried to test the sketche but here is the result :
Button 1 down
Buttons up
Button 1 down
Buttons up
Button 1 down
Buttons up
Button 1 down
Buttons up
Button 1 down
Buttons up
Button 1 down
Buttons up
always same ...
upload and wemosd1mini
do you have an idea?
thank you very much
regards,
jonathan
Hi Jonathan,
Thanks for using my library.
Did you connect the keypad to the analog pin A0 of the Wemos d1 mini?
Is the keypad input voltage connected to 3.3V?
Hello,
thanks for the answer, yes it's on the A0 and connected on 3.3v
Can you enable some diagnostics by following the steps below?
- Open the file
src/ErriezRobotDynKeypad3x4Analog.cpp
in a text editor and remove the comment on line 177:
// For debugging purposes
Serial.println(analogValue);
- Run the example
RobotDynKeypad3x4Analog
on your board. - Press buttons 0..11 after each other.
- Add the serial output in this comment.
I look forward to your output.
i have a 4x4 keyboard but i tested with tjhe 3x4 before to modify it.
i have the following error :
collect2.exe: error: ld returned 1 exit status
collect2.exe: error: ld returned 1 exit status
There is a compile error somewhere in your (modified?) library or sketch, but requires more details. To display the exact location of the build error, open Arduino IDE | File | Preferences | Show verbose output during: Check: compilation
, rebuild and scroll up in the output window.
I've tested the code below with a RobotDyn Analog 4x4 Keypad and following boards:
- UNO = Mega2560
- NodeMCU 1.0 ESP-12E Module = Generic ESP8266 module = LOLIN(Wemos) D1 R2 mini
- LOLIN D32 (ESP32 with OLED)
Can you copy/paste the code below to a new Arduino sketch, run this on your board and let me know if it works? Then I can extend the library to support a 4x4 keypad when it works for you:
/*
* MIT License
*
* Copyright (c) 2020 Erriez
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Arduino.h>
#if ARDUINO_ARCH_AVR
#define MAX_ANALOG_VALUE 1023
#elif ARDUINO_ARCH_ESP8266
#define MAX_ANALOG_VALUE 995
#elif ARDUINO_ARCH_ESP32
#define MAX_ANALOG_VALUE 4095
#else
#error "Unknown target"
#endif
class RobotDynKeypad4x4Analog
{
public:
explicit RobotDynKeypad4x4Analog(uint8_t analogPin, uint16_t maxAnalogValue=MAX_ANALOG_VALUE);
int getButtons();
protected:
uint8_t _analogPin;
uint16_t _maxAnalogValue;
};
RobotDynKeypad4x4Analog::RobotDynKeypad4x4Analog(uint8_t analogPin, uint16_t maxAnalogValue) :
_analogPin(analogPin), _maxAnalogValue(maxAnalogValue)
{
}
int RobotDynKeypad4x4Analog::getButtons()
{
int analogValue;
int button;
analogValue = analogRead(_analogPin);
#if ARDUINO_ARCH_AVR
analogValue = (int)map(analogValue, 0, _maxAnalogValue, 0, 1023);
if (analogValue < 220) {
button = -1;
} else if (analogValue < 251) {
button = 16;
} else if (analogValue < 297) {
button = 15;
} else if (analogValue < 364) {
button = 14;
} else if (analogValue < 421) {
button = 13;
} else if (analogValue < 450) {
button = 12;
} else if (analogValue < 470) {
button = 11;
} else if (analogValue < 493) {
button = 10;
} else if (analogValue < 535) {
button = 9;
} else if (analogValue < 581) {
button = 8;
} else if (analogValue < 616) {
button = 7;
} else if (analogValue < 655) {
button = 6;
} else if (analogValue < 732) {
button = 5;
} else if (analogValue < 821) {
button = 4;
} else if (analogValue < 893) {
button = 3;
} else if (analogValue < 977) {
button = 2;
} else {
button = 1;
}
#elif ARDUINO_ARCH_ESP8266
analogValue = (int)map(analogValue, 0, _maxAnalogValue, 0, 995);
if (analogValue < 230) {
button = -1;
} else if (analogValue < 268) {
button = 16;
} else if (analogValue < 313) {
button = 15;
} else if (analogValue < 382) {
button = 14;
} else if (analogValue < 443) {
button = 13;
} else if (analogValue < 472) {
button = 12;
} else if (analogValue < 495) {
button = 11;
} else if (analogValue < 519) {
button = 10;
} else if (analogValue < 562) {
button = 9;
} else if (analogValue < 609) {
button = 8;
} else if (analogValue < 644) {
button = 7;
} else if (analogValue < 686) {
button = 6;
} else if (analogValue < 770) {
button = 5;
} else if (analogValue < 862) {
button = 4;
} else if (analogValue < 938) {
button = 3;
} else if (analogValue < 1003) {
button = 2;
} else {
button = 1;
}
#elif ARDUINO_ARCH_ESP32
analogValue = (int)map(analogValue, 0, _maxAnalogValue, 0, 995);
if (analogValue < 150) {
button = -1;
} else if (analogValue < 182) {
button = 16;
} else if (analogValue < 226) {
button = 15;
} else if (analogValue < 287) {
button = 14;
} else if (analogValue < 343) {
button = 13;
} else if (analogValue < 375) {
button = 12;
} else if (analogValue < 394) {
button = 11;
} else if (analogValue < 413) {
button = 10;
} else if (analogValue < 455) {
button = 9;
} else if (analogValue < 505) {
button = 8;
} else if (analogValue < 538) {
button = 7;
} else if (analogValue < 573) {
button = 6;
} else if (analogValue < 652) {
button = 5;
} else if (analogValue < 748) {
button = 4;
} else if (analogValue < 840) {
button = 3;
} else if (analogValue < 946) {
button = 2;
} else {
button = 1;
}
#else
#error "Unknown target"
#endif
// For debugging purposes
// Serial.println(analogValue);
return button;
}
#define KEYPAD_ANALOG_PIN A0
RobotDynKeypad4x4Analog keypad(KEYPAD_ANALOG_PIN);
// Initial keypad state
static int keypadStateLast = -2;
void setup()
{
// Initialize serial port
Serial.begin(115200);
Serial.println("\nErriez RobotDyn analog 4x4 keypad example\n");
}
void loop()
{
int keypadState;
// Read buttons
keypadState = keypad.getButtons();
// Print button state only when it changed
if (keypadState != keypadStateLast) {
keypadStateLast = keypadState;
if (keypadState == -1) {
// -1: All buttons up
Serial.println(F("Buttons up"));
} else {
// 0..15: Button down
Serial.print(F("Button "));
Serial.print(keypadState, DEC);
Serial.println(F(" down"));
}
}
delay(100);
}