0

I am using the keypad library to include keypad and input numbers. when a specific number is entered a sound must be made. However when I input using the serial monitor , sound is working. But when I include keypad , it only inputs numbers but not sound. Help please , how can I make both work? Thanks.

#include <Keypad.h> const byte ROWS = 4; //four rows const byte COLS = 4; //four columns char keys[ROWS][COLS] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad byte colPins[COLS] = {8,7,6,5}; //connect to the column pinouts

Then I get the input from keypad and store as result

char guess = 'n'; char keypressed = keypad.getKey(); if (keypressed != NO_KEY) { char guess = keypressed;

in void loop, it get result(key from keypad) and must play it: Tried separate sketch it works. but with keypad only input is , not sound.

Serial.print("You guessed:"); Serial.println(guess); result = checkYourself(guess); Serial.println(result); playSound(result);

check yourself takes in guess from keypad ,checks then returns as result. play sound function works when tried in another sketch( sorry not posting too much code its very long)

  • 3
    it is difficult to determine the problem area without seeing your code ... please include minimal sketch that still exhibits the undesired behavior – jsotola Nov 7 at 20:34
  • I just posted it thanks. – Rhea Ramtohul Nov 7 at 21:30
  • which pin are you using for the buzzer? – jsotola Nov 7 at 21:39
  • using pin 9 .... – Rhea Ramtohul Nov 7 at 21:52
  • which pins does the keypad use? – jsotola Nov 7 at 22:04
0

Please make sure that the pin connected to piezo does NOT used by keypad

0

I was able to solve it , piezo dissent work in pin 9 but works when connected to pin 13.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.