Step 1:





Step 2:

The button() function adds a button to the UI tab.

Add a button for each answer to the question, as many as you want, and click "Run." You will be able to click the buttons, but they won't do anything yet.



Step 3:

Use the Add State button to create two new states. Call one "yes" and the other "no".



Step 4:

In the "yes" state, add three lines of code: Then add the same three lines to the "no" state, except the label should display "Incorrect".



Step 5:

Now we need to make each button connect to one of the "yes" or "no" states.

To connect a button to a state, add the name of the state after the name of the button, separated by a comma, like this: button("Purple", "no")

Connect each correct answer to the "yes" state, and each incorrect answer to the "no" state, as in the example below, and click "Run".

Now each time you click one of the buttons, it will display either "Correct" or "Incorrect" for one second and then return to the question.



Step 6:

All that is left is to add code to make the Quizbot respond to the answers.

To begin, experiment with the Drive tab to find which Quizbot servo is servo[0] and which is servo[1]. In our example, the up-down servo is servo[1]. Then add these lines of code:




Congratulations, your code is complete! Run the code and try out your question. Ask other students to answer the question as well!