Math Test Using Arduino | Arduino Project

by | Nov 24, 2022 | Arduino, Coding

Introduction

Today we are going to learn how to create a Math Test using Arduino. In this project, we will use pushbuttons and an LCD screen to display a time-based test.

For physical projects, the components can be purchased online or from any electronics center. For online projects, the TinkerCad website can be used.

 

Supplies

In order to create a Math test using Arduino, the following components will be required:

Components

  • Arduino Uno R3
  • 2 PushButtons
  • LCD 16×2
  • One small BreadBoard
  • 3 Resistors
  • Connecting wires

Circuit Diagram

Math Test Using Arduino | Arduino Project

 

Steps To Create A Math Test Using Arduino

Step 1: Gather all the components on the Digital Board or Physical Table.

Step 2: Plug PushButtons on the BreadBoard.

PushButton:

Step 3: Connect the 1st terminal of each to the 5V pin of the Arduino.

Step 4: Connect the 2nd terminal of each to the GND pin of the Arduino.

Step 5: Connect the 3rd pin of it to the 10 & 11 number pin of the Arduino, resp.

LCD:

Step 6: First, Connect the Power & the LED anode terminal of it to the 5V pin of the Arduino.

Step 7: Then Connect the Ground, Contrast, and Read/Write & LED cathode terminals of it to the GND pin of the Arduino, as shown in the circuit.

Step 8: Now Connect the Register Select, Enable, & DB4 to DB7 pins of it to the 2 to 7 number pins of the Arduino, respectively, as shown in the figure.

Source Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

int a = 10, b = 11;

int A;

int score = 0;

void setup()

{

Serial.begin(9600);

lcd.begin(16,2);

pinMode(a, INPUT);

pinMode(b, INPUT);

}




void loop()

{

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Choose the ");

lcd.setCursor(0, 1);

lcd.print("correct answer ");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("5m is a monomial");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);




A = digitalRead(a);

Serial.print(A);

if(A == 1)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("TRUE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("cosine = b/h");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);

A = digitalRead(a);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("TRUE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("LCM of 15 is 2,5");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);

A = digitalRead(b);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("FALSE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("sin(0) = 3/4");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);




A = digitalRead(b);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("FALSE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("tan(45) = 1");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);




A = digitalRead(a);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("TRUE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("1m = 100cm");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);




A = digitalRead(a);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("TRUE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("d(r2)/dr = 2r");

lcd.setCursor(0, 1);

lcd.print("a)True b)False");

delay(5000);




A = digitalRead(a);

Serial.print(A);

if(A == HIGH)

{

score = score + 5;

}




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("TRUE");

delay(2000);




lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Final Score = ");

lcd.setCursor(14, 0);

lcd.print(score);

delay(5000);



}

 

Explanation of the Code

1. We have included a header file for LCD at the beginning of the code.

2. Next, we initialized arrays and variables that will be required in the function.

3. In the setup function, we have declared the LCD as having 2 rows and 16 columns. Also, we have configured the pin mode for input purposes and began the serial connection with 9600 bits per second.

4. In the loop function, we display the options, along with the question, and give 5 seconds of time to the candidate to give the answer to that question using the push button. If the answer is right, the candidate will get 5 points, and at last, the final score will be displayed.

Purpose of Functions Used In The Code:

  • lcd.clear() function will help to clear the screen of the LCD.
  • lcd.print() function prints the text in the LCD,
  • lcd.setCursor function helps to set the cursor in the LCD.
  • The delay function takes time in milliseconds, using which the candidate will be given 5 seconds of time to answer each question.

Output

We will get the following output on the successful completion of this Arduino project.

Math Test Using Arduino

On starting the simulation, we will be able to see the display in LCD and see our final score at the end of the test.

 

 

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *