softboard, serial menu example: access to arduino pins over a menu

From the very start of my Arduino exploration I was looking for more feedback from the Arduino then just blinking LEDs,
so I used things like sound on piezzos, LCDs displays and good old serial communication to access my projects.

Over time I developed a kind of serial menu interface to test parts of arduino projects while developping.
Often the serial menu stayed in the project, sometimes I removed it later when everything worked as expected.

softboard GitHub - reppr/softboard: arduino software breadboard is an example of this serial menu being used to access Arduino hardware pins.

It can be quite useful for hardware/software testing as a kind of software breadboard checking things like:

  • Does that led on pin 13 work?
    'D13 OH' Arduino type "hello world" effect.
    'D13' selects digital pin13, 'O' configure as output, 'H' switches it high.

  • Read that pin now.
    'd'

*pin 13	O  HIGH
  • What raw data does this new analog sensor on pin A3 give right now?
    Enter 'A3 a' without the quotes and then
    'A3' selects analog pin A3, 'a' reads one value:
pin	value	|				|				|
*A3	282	******************
  • You want an easy way to see a value and bar graph display showing all changes while you test your sensor.
    'A3 v' activates continuous VU display, 'v' stops it again.
pin	value	|				|				|
*A3	41	***
*A3	51	****
*A3	101	*******
*A3	205	*************
*A3	226	***************
*A3	243	****************
*A3	242	****************
*A3	209	**************
*A3	0	0
*A3	4	*
*A3	14	*
*A3	36	***
*A3	61	****
*A3	91	******
*A3	121	********
*A3	157	**********
*A3	191	************
*A3	251	****************
*A3	313	********************
*A3	308	********************
*A3	258	*****************
*A3	75	*****
*A3	28	**
*A3	0	0
*A3	1	*
  • What PWM value do I need on pin 10 to let the motor start?
    'D10 W23' 'D10' selects digital pin 10, 'W20' writes PWM value 23

  • What will my quick breadboard test do when I set this pin to HIGH, the other one LOW and then wait for a third one to change
    while watching the temparature sensor analog readings....?

  • Set and show configuration of all the pins.
    'D4OL D5OH D8IH D9IL D13IH' selects some digital pins, configures them as inputs 'I' or outputs 'O', sets them 'H' high or 'L' low.
    '.' now shows state of all digital pins:

You can omit the spaces and just say 'D4OLD5OHD8IHD9ILD13IH .'

 pin 0	I  floating
 pin 1	I  floating
 pin 2	I  floating
 pin 3	I  floating
 pin 4	O  LOW
 pin 5	O  HIGH
 pin 6	I  floating
 pin 7	I  floating
 pin 8	I  pullup
 pin 9	I  floating
 pin 10	I  floating
 pin 11	I  floating
 pin 12	I  floating
*pin 13	I  pullup

So far so good, but why does your LED glow so faintly now :wink:

  • Test Arduino system: What happens if you write high to an input pin?
    'D11 L I H' selects digital pin 11, writes low, configures as input and then writes high:
*pin 11	I  floating
*pin 11	I  pullup

CPU time friendly implementation:
Softboard tries not to block the processor longer then needed to let as much CPU time as possible
to any other code possibly running.

serial_menu() will just run through it's code and then return immediately.

The code went through major changes these days and needs more testing. Please give feedback.

Have fun!