false triggering issue with PB5 in Arduino Nano

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using arduino nano (CH340 based china make) for some hobby project. I used PB5 for keypad as shown in the schematic.

But the problem is that when I press button 1 sometimes I get 2, 3 or A key detection. Similarly when I press key 4, other keys such as 5, 6 or B is also getting triggered. But if I use PD4 instead of PB5, there is no issue.

Looking at nano board schematic, PB5 is connected to SCK LED through 330 ohm resistor. Does this have impact on keypad scan? Do I need to replace 330 ohm resistor with 1K?

// Please note: pin numbers given here is only for reference. Actual code
// implements this differently using unique pin number

uint8_t rowBitNumbers[NUM_ROWS] = {PB5,PD2,PD3,PB4};
uint8_t columnBitNumbers[NUM_COLS] = {PC3,PC2,PC1,PC0};

uint8_t  keyAssignments[4][4] = {
		{'1', '4', '7', '*'},
		{'2', '5', '8', '0'},
		{'3', '6', '9', '.'},
		{'A', 'B', 'C', 'D'},
	};

Note: rowBitNumbers[] are are kept as inputs by default and whenever we scan through columnBitNumbers[], these rows are configured one after the other as low outputs first and then columns are scanned. Columns are pulled upto through 10K resistors.

This topic has a solution.

Last Edited: Tue. Jul 24, 2018 - 04:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the well-known phenomenon known as contact bounce.

 

The solution is called de-bouncing.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
This is the well-known phenomenon known as contact bounce.

Maybe not, it could be your 10k pull ups are not strong enough to pull the line high with the LED on it, I would try it with 4k7 or 2k2 pull ups to see if that helps.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Key debounce is anyway taken care.

But I am not sure how debouncing triggers adjacent keys. It can trigger same key again in next while() iteration.

 

I kept all rowBitNumbers[] as inputs initially and then make one of them output and scan all columnBitNumbers[] one after the other (names rows and columns probably misleading in this case and have to be interchanged) and then again make  rowBitNumbers[] as inputs.

 

With rowBitNumbers[0]= LOW, I can scan switches 1,4,7 and *

Now rowBitNumbers[0] is made as input again and even if switch bounces, I am not scanning that uintil I come back again for next iteration of while(1) loop.

 

However if ATMEGA takes time to change states from input to output or vice versa, something like this can happen I guess. So I added SWITCHING_DELAY of 1 msec but still same issue.

Secondly if PB5 is changed to PD4, everything works fine. 

 

So as @ki0bk suggested, I may have to go for strong pull up or may be I have to increase 330 ohm resistor of LED to 1K.

 

below is the code snippet. There are some other functions such as readSwitch() and could not add here due to some dependencies. Also rowBitNumbers[NUM_ROWS] values are given only for reference. In reality I am making use of unique numbers similar to arduino.

#define SWITCHING_DELAY 1
unsigned char getKeyStatus(void)
{
    unsigned char rowLoopCount;
	unsigned char columnLoopCount;
	unsigned char retValue=NO_KEY_DETECTED;

    		 /** In case keypad is multiplexed with LCD or other peripherals
                we need to take care here
                Note that all scan inputs must be configured as inputs
                That is why this extra loop
		    */

	for(rowLoopCount=0;rowLoopCount<NUM_ROWS;rowLoopCount++)
	{
		pinMode(rowBitNumbers[rowLoopCount],INPUT);
		//digitalWrite(rowBitNumbers[rowLoopCount],HIGH);
		pinMode(columnBitNumbers[rowLoopCount],INPUT);
	}


	//Loop for maximum rows configured
	for(rowLoopCount=0;rowLoopCount<NUM_ROWS;rowLoopCount++)
	{
		// Make the Row as output port. So row will be low (No need to set low because default is low)
		pinMode(rowBitNumbers[rowLoopCount],OUTPUT);
        //digitalWrite(rowBitNumbers[rowLoopCount],LOW);
		//  Read each column.
		CL_delay_mS(SWITCHING_DELAY);

		for(columnLoopCount=0;columnLoopCount<NUM_COLS;columnLoopCount++)
		{
			//Read  the status of the switch
			//pinMode(columnBitNumbers[columnLoopCount],INPUT);
			uint8_t status = readSwitch(columnBitNumbers[columnLoopCount]);
			//pinMode(columnBitNumbers[columnLoopCount],OUTPUT);
			if(status)
			{
				pinMode(rowBitNumbers[rowLoopCount],INPUT);
				digitalWrite(rowBitNumbers[rowLoopCount],HIGH);
				// Restore columns back as outputs in case they are multiplexed
				return(keyAssignments[rowLoopCount][columnLoopCount]);
			}
		}
		// At the end, change the direction as input so that port goes to high impedance
		pinMode(rowBitNumbers[rowLoopCount],INPUT);
		digitalWrite(rowBitNumbers[rowLoopCount],HIGH);
		CL_delay_mS(SWITCHING_DELAY);
	}
	return(retValue);
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have a formal written algorithm (or flowchart or trace diagram or documentation) that explains what the code is actually doing, or are we expected to just plow through it like we are all just a bunch of 1970's UNIX engineers?

 

Did you have a formal written algorithm (or flowchart or trace diagram or documentation) that explains what the code is actually going to be doing, before you started writing this code?  Or is it a copy-and-paste job from some code that some guy said "worked"?   Do you know how to make a IBM flow chart, Nassi-Shneiderman diagram https://en.wikipedia.org/wiki/Na..., or Warnier-Orr algorithm https://en.wikipedia.org/wiki/Wa... These are software design tools used before the coding begins to avoid big messes in what should be a simple code process.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are doing an Arduino project and using a keypad, then you should be developing your project with a keypad exactly like the one above that is widely available on eBay for under a dollar US.  There are lots of good plug'n'play code libraries for this module.  After you get the code working on the same cheap ubiquitous standardized eBay hardware and modules that everybody else uses at this stage of the development process, then and and only then can you transfer and adapt your working code to your hand-wired point-to-point keyboard masterpiece and expect it to work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How long is the cable to the keypad? Sounds like capacitance vetween the wires. The external pullups should cure this along with the select delay. If you have an oscilloscope, i’d suggest you have a look at the signals.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using the keypad that is available for less than a $ in ebay and length is hardly 60-70 mm. I looked at oscilloscope, but could not makeout much.

Only thing I can say is that if PD4 is connected instead of PB5, everything is perfect. So it is clear indication that PB5 is the one which troubles me here. I have to probably lift SCK LED or its resistor and try next to verify this.

 

Below is the complete code. Key debounce is a crude method and I am yet to implement using timers. As indicated earlier, I am using Arduino nano (Chinese version having CH340).

 

#include <avr/io.h>

#include <util/delay.h>

 

#ifndef F_CPU

#define F_CPU 16000000UL

#endif

 

#undef HIGH

#define HIGH 1

 

#undef LOW

#define LOW 0

 

#undef OUTPUT

#define OUTPUT 1

 

#undef INPUT

#define INPUT 0

 

#ifndef IOPORTB

#define IOPORTB 0

#endif

#ifndef IOPORTC

#define IOPORTC 1

#endif

#ifndef IOPORTD

#define IOPORTD 2

#endif

 

#define IOPB0  0

#define IOPB1  1

#define IOPB2  2

#define IOPB3  3

#define IOPB4  4

#define IOPB5  5

#define IOPB6  6

#define IOPB7  7

#define IOPC0  8

#define IOPC1  9

#define IOPC2  10

#define IOPC3  11

#define IOPC4  12

#define IOPC5  13

#define IOPC6  14

#define IOPC7  15

#define IOPD0  16

#define IOPD1  17

#define IOPD2  18

#define IOPD3  19

#define IOPD4  20

#define IOPD5  21

#define IOPD6  22

#define IOPD7  23

 

#define IOBitSet(ioport, bit) (((ioport)==IOPORTD)?(PORTD|=1<<(bit)):((ioport)==IOPORTB)?(PORTB|=1<<(bit)):((ioport)==IOPORTC)?(PORTC|=1<<(bit)):0)

#define IOBitClear(ioport, bit) (((ioport)==IOPORTD)?(PORTD&=~(1<<(bit))):((ioport)==IOPORTB)?(PORTB&=~(1<<(bit))):((ioport)==IOPORTC)?(PORTC&=~(1<<(bit))):0)

#define IOBitDirOut(ioport, bit) (((ioport)==IOPORTD)?(DDRD|=1<<(bit)):((ioport)==IOPORTB)?(DDRB|=1<<(bit)):((ioport)==IOPORTC)?(DDRC|=1<<(bit)):0)

#define IOBitDirIn(ioport, bit) (((ioport)==IOPORTD)?(DDRD&=~(1<<(bit))):((ioport)==IOPORTB)?(DDRB&=~(1<<(bit))):((ioport)==IOPORTC)?(DDRC&=~(1<<(bit))):0)

#define IOBitInvert(ioport, bit) (((ioport)==IOPORTD)?(PORTD^=1<<(bit)):((ioport)==IOPORTB)?(PORTB^=1<<(bit)):((ioport)==IOPORTC)?(PORTC^=1<<(bit)):0)

#define portRead(ioport) (((ioport)==IOPORTD)?(PIND):((ioport)==IOPORTB)?(PINB):((ioport)==IOPORTC)?(PINC):0)

 

#define pinMode(pin,mode) (((mode)==OUTPUT)?IOBitDirOut(((pin)/8),((pin%8))):IOBitDirIn(((pin)/8),((pin)%8)))

#define digitalWrite(pin,value) (((value)==LOW)?IOBitClear(((pin)/8),((pin)%8)):IOBitSet(((pin)/8),((pin)%8)))

#define digitalRead(pin) ((portRead((pin)/8))&(1<<((pin)%8))?HIGH:LOW)

#define digitalInvert(pin) (IOBitInvert(((pin)/8),((pin)%8)))

 

#define NUM_OUTPUT_PINS 4 // Number of rows in the keypad

#define NUM_INPUT_PINS 4 // number of columns in the keypad

#define NO_KEY_DETECTED '\0'   // When no key is detected, return '\0'

 

#define KEYPRESS_RESTARTED 0xff

#define KEYPRESS_IN_PROGRESS 0xfE

#define KEY_DEBOUNCE_TIME 20

#define SWITCH_TYPE ACTIVE_LOW

 

#define SWITCHING_DELAY 1      // delay between row switching.

 

uint8_t  getKeyStatus(void);

 

uint8_t keyOutputPins[NUM_OUTPUT_PINS] = {IOPB5,IOPD2,IOPD3,IOPB4};

uint8_t scanInputPins[NUM_INPUT_PINS] = {IOPC3,IOPC2,IOPC1,IOPC0};

 

uint8_t  keyAssignments[4][4] =

{

    {'1', '4', '7', '*'},

    {'2', '5', '8', '0'},

    {'3', '6', '9', '.'},

    {'A', 'B', 'C', 'D'},

};

 

unsigned char readSwitch(unsigned char columnNum)

{

 

    /**Crude method of key debounce. Timer based debounce is to be implemented */

    if(!digitalRead(columnNum))

    {

        _delay_ms(KEY_DEBOUNCE_TIME);

        if(!(digitalRead(columnNum)))

        {

            return(1);

        }

 

    }

    return(0);

 

}

 

unsigned char getKeyStatus(void)

{

    unsigned char outerLoopCnt;

    unsigned char innerLoopCnt;

    unsigned char retValue=NO_KEY_DETECTED;

 

    /** In case keypad is multiplexed with LCD or other peripherals

       we need to take care here

       Note that all scan inputs must be configured as inputs at the beginning

       That is why this extra loop

       In case keypad is not multiplexed, comment this loop

       or make use of conditional compilation

    */

 

    for(uint8_t index=0; index<NUM_OUTPUT_PINS; index++)

    {

        pinMode(keyOutputPins

,INPUT);

        // Do not know the state of pins. Make them high

        digitalWrite(keyOutputPins

,HIGH);

        pinMode(scanInputPins

,INPUT);

    }

 

    //Loop for maximum output lines configured

    for(outerLoopCnt=0; outerLoopCnt<NUM_OUTPUT_PINS; outerLoopCnt++)

    {

        // Make the Row as output port and Low.

        pinMode(keyOutputPins[outerLoopCnt],OUTPUT);

        // Make it one of the pins low and scan all scan lines.

        digitalWrite(keyOutputPins[outerLoopCnt],LOW);

        //  Read each input line.

        _delay_ms(SWITCHING_DELAY);

 

        for(innerLoopCnt=0; innerLoopCnt<NUM_INPUT_PINS; innerLoopCnt++)

        {

            //Read  the status of the switch

            uint8_t status = readSwitch(scanInputPins[innerLoopCnt]);

            if(status)

            {

                // change the state back to input.

                pinMode(keyOutputPins[outerLoopCnt],INPUT);

                return(keyAssignments[outerLoopCnt][innerLoopCnt]);

            }

        }

        // At the end, change the direction as input so that port goes to high impedance

        pinMode(keyOutputPins[outerLoopCnt],INPUT);

        _delay_ms(SWITCHING_DELAY);

    }

    return(retValue);

}

 

int main(void)

{

    /** Initialize UART. Below method is crude way of doing  and need to change*/

    UCSR0B |= (1<<RXEN0)|(1<<TXEN0);

    UBRR0 = 103;  // 9600 Baud

 

    while(1)

    {

        uint8_t key = getKeyStatus();

        if(key)

        {

            while(!(UCSR0A & (1<<UDRE0)));

            UDR0=key;

        }

    }

}

Below is what I get in terminal software when buttons 1 and 4 are pressed respectively

 33 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31

 

34 34 34 34 34 34 34 34 34 34 34 36 34 34 34 34 34 34 34 34 36 34 34 34 34 34 34 34 34 42 34 34 34 34 34 34 34 34 42 34 34 34 34 34 34 34 34 34 42 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 36 34 34 34 34 34 34 34 42 34 34 34 34 34 34 34 36 34 34 34 34 34 34 36 34 34 34 34 34 34 42 34 34 34 34 34 34 34 42 34 34 34 34 34 34 34 

Last Edited: Tue. Jul 24, 2018 - 01:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, talk about obfuscated code! I tried to follow that to work out what's going on but I gave in I'm afraid. Hope you can find someone else with more patience / perseverance.

 

BTW If you have this:

		{'1', '4', '7', '*'},
		{'2', '5', '8', '0'},
		{'3', '6', '9', '.'},
		{'A', 'B', 'C', 'D'},

and then do this:

            while(!(UCSR0A & (1<<UDRE0)));
            UDR0=key;

and finally get this:

 33 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 41 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 32 31 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31 33 31 31 31 31 31 31 31 31 31

can we take it you have some terminal software set to some kind of "hex codes" mode?

 

As '1' (31), '3' (33) and 'A' (41) are all in the same vertical column it clearly hints at some kind of row numbering issue?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
a IBM flow chart

Do/did IBM have their own special type of flowchart??

 

But agree wholeheartedly about the importance of doing design before coding!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I used terminal software in Hex mode. This is the result when I press and hold key 1. 

I see 32 ('2') and 41 ('A') getting reported when 1 is pressed.

Row numbering even if wrong, one key should report same result every time and not different results.

 

Last Edited: Mon. Jul 23, 2018 - 04:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joneewheelock wrote:
rows are configured one after the other as low outputs first and then columns are scanned. Columns are pulled upto through 10K resistors.

 

This seems backwards to me, as inputs should have pull ups and the rows should be high scanned low to look for a low input signal where a button is pressed.

If I have read the description correctly, the inputs are floating when no button is pressed, if so, that would explain false button detection and the wrong values seen.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Mon. Jul 23, 2018 - 04:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am sorry for the confusion. Names rows and columns got interchanged and I indicated it in my OP. I edited the full code now and hopefully it clears the confusion.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have the blue, white, and red membrane keypad shown in photo?   Are you using the keypad with 60-70 cm (about 25 inches) wires between the key pad and input port?

If you have the membrane keypad shown above, what is the result when you connect it to the Arduino (according any pin connection documentation) and run a working membrane-keyboard library that you downloaded from GitHub?

 

 

In school I had a plastic template for tracing out the flow chart symbols; the elongated diamond, the trapezoid, rectangle, circle, etc.  It was marked IBM flow chart symbols.  Way back then, IBM was the leading company of information age. Now,... do they still exist?  Hence, the reference to IBM flow chart symbols.  I never really used it.  Instead we learned the Warnier-Orr algorithm design method.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I'm understanding all this correctly, when you push a button to connect PB5 to any of the input pins, and PB5 is not being driven low, you have completed the circuit 10k--330--LED, with the input reading the voltage between the 10k and the 330.  The 10k will not be able to pull up that input any higher than the LED voltage (the 330 is pretty much a short circuit, being 30 times smaller than the 10k).  So instead of reading Vcc on the input pin, you're essentially reading Vled, which is no doubt below the Vhi minimum voltage for the input pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@moderator: 

 

Not related to the subject of the post, but related to to editing issue:

 

After I edited the code in #8 above, the code appears completely broken. For example:

for(uint8_t index=0; index<NUM_OUTPUT_PINS; index++)
    {
        pinMode(keyOutputPins

,INPUT);

 

[] got removed in many places.

 

But if I go to edit mode there is no issue. Tried to delete and add code again. But does the same again. What needs to be done? I used <> to post the code as usual.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Best way to "edit" code is edit it in your normal C editor. When you have it looking right simply place the cursor in the existing ode of your edited posts above and click "<>". When you first enter the editor the entire text is selected. Now just Ctrl-V your complete new version on top to completely replace ALL the existing text. It should have the same text layout as you saw in your own C editor.

 

(I would NOT recommend using the code editor on this site for actually WRITING your code for 2 reasons: 1) it's the most underspecified code editor on earth and 2) What are you going to do with it anyway? Presumably you want the copy for your AVr updated with the same changes? So do you plan to then copy it back off this website and into your editor? Why wouldn't you just make the edits that you  want in your own code editor in the first place?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
In school I had a plastic template for tracing out the flow chart symbols

So did I:

 

ICL was a British computer manufacturer; "CES" was "Computer Education in Schools" - a programme which they sponsored.

 

Doesn't mean that the flowchart symbols are specific to ICL or the CES programme - they aren't even limited to computer programming!

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your review could be correct I feel.

Attached two images measured on PB5. In one of them, I see around 2.5 volts.

I need to try with 1K LED resistor or 1K pull up.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Infact I did exactly what you suggested. I used codeblocks and formatted and copied that code. Never had this issue until now and only today not able to update the code. There seems to be an issue with editor today as I tried to add code here also again, but entire code appears in single line. I will try to add the code tomorrow.

 

 

 

Last Edited: Mon. Jul 23, 2018 - 05:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone preserved the code from #8 above? Appreciate if that could be posted back. I lost my local copy in the process of copy paste and I need to update again. The code in the post #8 is completely broken due to formatting issue.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Do you know how to make a IBM flow chart, Nassi-Shneiderman diagram https://en.wikipedia.org/wiki/Na..., or Warnier-Orr algorithm https://en.wikipedia.org/wiki/Wa...

That's a little harsh, and a bit of over-kill, IMHO.

 

I'm not much of a programmer, (admittedly), but I've still been coding for over 40 years, generally successfully, and have never used a NS diagram or a WO algorithm.

 

I use a flow chart, sometimes on several pages of paper taped together.

 

It's simple and it works.

 

It is, I suspect, sufficient for designing a keypad scanning routine.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

 Do you know how to make a IBM flow chart, Nassi-Shneiderman diagram https://en.wikipedia.org/wiki/Na..., or Warnier-Orr algorithm https://en.wikipedia.org/wiki/Wa...

That's a little harsh, and a bit of over-kill, IMHO.

I think you missed the "or" ?

 

The point is that there are many tools and techniques; the important thing is to do the design - not which tool/technique you use.

 

Of course you wouldn't use all of them!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Jul 24, 2018 - 06:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got one nano board with faulty SCK LED. Works fine in that. So it now clear that the issue is due to SCK LED and resistor.