How do i generate a console for questionnaires with Arduino?

Hello to everyone,

i’m a newcomer here on the forum. I have a quite little experience in programming: i learnt programming in C during my bachelor degree and i have tried using Arduino for some applications here at home during my free time.

I kindly ask you some tips from you for a little project i need to create for my further studies: altough we aren’t studying Arduino, it was assigned to me to develop a sort of “console” that consists in a couple of displays, twelve buttons and an Arduino board.

The purpose of this project is to create a system that would be capable, by means of a serious game, of raising awareness in the players about sustainability for the industrial processes.
I developed the theoretical part of this project, and the phisical concretization is this console with two displays for the two players and with six buttons per each of them: the displays would show some questions subsequently (“How do you purchase this apparatus?”, “how do you think this component will be disposed?” and so on), provide six alternatives for the choice and the players have to choose the most proper one by pushing one of these six buttons.

The point is that i don’t know how to manage this flow of choices with Arduino.
I initially tought of a series of cycles “while” and “if” (i.e. “while a button is not pressed, print this question”; “if button 1 is pressed then do your calculi for the final verdict”), but i don’t know how to build a proper flowchart/flux of information in the listing.

The questionnaire consists in 9 questions, and for each one of them there will be six alternatives for the choice. After that the question has been shown on the display, Arduino should wait the answer from the player; when he chooses its preference, then Arduino would move to the next question and so on up to the last question and lastly the results both for the firm’s point of view (the players are persuaded they are developing a product for their firm in the most competitive way) and from the sustainability p.o.v. (this unexpected further verdict could educate the player).

Moreover, now i have Covid (luckily i’m fine!) but i cannot operate anymore on my Arduino Mega 2560 (i have it in my garage and i live in a condominium), so my professor agreed on letting me use Tinkercad and provide him just a simulation of the device: for this reason, only the Arduinos available on Tinkercad are compatible with this project, and so for the displays (if i’m not wrong, there is only a LED screen 16x2).

I’m sorry for this veeeery long post. I hope i made myself clear; i really would appreciate any suggestion.
Thank you very much in advance,
Stefano :smiley:

@northwind89

Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

isn't it quite simple one after the other?

Print Question 1
Wait until an answer button is pressed
Print Question 2
Wait until an answer button is pressed
Print Question 3
Wait until an answer button is pressed
...
Show result

northwind89:
The point is that i don't know how to manage this flow of choices with Arduino.
I initially tought of a series of cycles "while" and "if" (i.e. "while a button is not pressed, print this question"; "if button 1 is pressed then do your calculi for the final verdict"), but i don't know how to build a proper flowchart/flux of information in the listing.

My first thought is that this seems a strange project for an Arduino. It seems to me it would be much more appropriate on a laptop of Raspberry Pi with the choices appearing on screen where a lot more explanation could be provided and where changes could more easily be made.

Do you have any idea why you were asked to implement it on an Arduino?

Assuming it must be implemented on an Arduino I think a State Machine (look it up) approach would be useful. The main states would be the different questions. For example in state1 it would be expecting an answer to question1 and then it would move on the state2, display question2 and expect the answer to question2

I strongly suggest that you don't use blocking code - i.e. FOR, WHILE or delay() - if it will block the Arduino for more than a few millisecs.

...R
Planning and Implementing a Program
Several Things at a Time
Using millis() for timing. A beginners guide

...R

or even ..

Beginners: using the switch - case statement

I'd be inclined to put the questions and multiple choice answers into arrays and make the code generic. That way, your number of questions isn't hard coded and you can easily modify them or use the same setup for a different quiz.

Better yet, read the data from an SD card.

I'm equally as baffled as Robin2 as to why you would choose an Arduino for the project.

Thank you to everybody!

Ballscrewbob, actually i read that topic but didn't find/notice any instruction on where to put my question nor i found analogue questions in the forum before posting my question... BTW it's my fault, i'm sorry for this. I will be more careful.

Noiasca, thank you for the hint. I will try to apply this pattern (that seems quite simple and could fit my ...case! ( :grinning: )

Robin2, thank you for your suggestion: i will investigate on it. With regards to the while/if i totally agree, that's why i haven't still been capable of doing something good up to now. I think i was asked to use Arduino because when during the lecture it has been asked "who knows this or that programming language" i said that i've used both C and Arduino, although i said that i wasn't so good at the both of them. I presume a further objective is to enhance our previous skills (this is the course of Virtual Prototyping).

Johnerrington, many thanks to you too!

Wildbill, the arrays thing is a very good idea - il try to do so!

I really appreciate you help! I hope this works! :smiley: :smiley:

Stefano

I am curious about the responses.

I can see the arrays
first one tracks what question one is on.
the next is to display 1 of 9 questions
next is to display 1 of 6 answers.
I assume some sort of final report of the answers or some judging etc.

if the OP is to write the code, I assume in some variation of C, does the platform make a lot of difference ?

I could see how doing it as a web page would be totally different than doing it in C.

as for the OP, I would recommend you sketch out the flow line for one question.
as was noted, each of the other 8 would be exactly the same, just different wording.

dave-in-nj:
if the OP is to write the code, I assume in some variation of C, does the platform make a lot of difference ?

It depends on the aim of the assignment I think. If the quiz is the desired end result, why bother hooking up displays and buttons to an Arduino when you could just as well use a Pi (or any other PC).

If as just suggested, the point may be to for the OP to improve his Arduino skills, then sure.