Divisibility Rules

by eeksteam in Teachers > 5

18 Views, 0 Favorites, 0 Comments

Divisibility Rules

IMG_20251004_150239.jpg
IMG_20251004_145151.jpg

EXPLORING DIVISIBILITY RULES: DIVISIBILITY RULE BY 3

The aim is to help students discover the rule: If the sum of a number’s digits is evenly divisible by 3, then the number itself is divisible by 3. Thanks to @OpenFab, students can explore this divisibility rule in a fun and engaging way.

Supplies

MATERIALS NEEDED:

• Arduino Uno

• OLED screen (SSD1306)

• 2 LEDs (green and red)

• 1 buzzer

• 1 button

• 1 potentiometer

• Resistors and jumper wires

INSTALL REQUIRED LIBRARIES

You will use Wire.h, Adafruit_GFX.h, and Adafruit_SSD1306.h libraries for the OLED display.

MAKE THE CONNECTIONS on BREADBOARD

• Connect LEDs:

Green LED → Pin 9

Red LED → Pin 8

• Connect Buzzer → Pin 7

• Connect Button → Pin 3

• Connect Potentiometer: first pin → GND, middle pin → A0, third pin → 5V

• Connect OLED screen

VCC → 3.3V , GND → GND , SCL → A5 , SDA →A4

DEFINE VARIABLES

• Define pins for LEDs, buzzer, button, and potentiometer.

• Create an OLED display object:

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire,

OLED_RESET);

CREATE a MELODY

• The buzzer will play 3 notes if the number is divisible by 3. If not, the buzzer will play its own sound.


void correctMelody() {

tone(buzzer, 523, 200); // C5

delay(250);

tone(buzzer, 659, 200); // E5

delay(250);

tone(buzzer, 784, 200); // G5

delay(250);

noTone(buzzer);

}

SETUP() FUNCTION

divisibility by 3 intro.PNG

• Set LED, buzzer, and button pins.


• Initialize the OLED display and set color to white:

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

display.clearDisplay();

display.setTextColor(SSD1306_WHITE);


• Display the starting message:

display.setTextSize(2);

display.setCursor(0,0);

display.println("3-divisibility");

display.display();

delay(2000);

DISCOVER THE RULE

green-number 18.PNG
red-number 122.jpg

• Create 8 different numbers that student will see on the OLED screen:

int mixed[8] = {122, 21, 39, 100, 22, 25, 45, 18};


• Display the numbers one by one in random order, keeping each number on the screen for 3 seconds. The teacher may ask students to take notes: numbers with the green light are evenly divisible by 3, and numbers with the red light are not, helping them understand the rule.

• If the number is evenly divisible by 3: green LED lights up, buzzer plays the melody.

• If the number is not divisible: red LED lights up, buzzer plays short buzzer tone.

STUDENT TEST WITH POTENTIOMETER

51-yes.jpg
73-no.jpg
IMG_20251004_143918.jpg

• After discovering the rule, students will try their numbers by using the potentiometer. They can change the number that is seen on the OLED screen. Then, by pressing the button, they will check if the number is evenly divisible by 3 or not.


• Read the potentiometer from A0 and map it to 1–99:

int potValue = analogRead(potPin);

int number = map(potValue, 0, 1023, 1, 99);


• Display the number on the OLED.

• When the button is pressed:

If evenly divisible by 3: display “Divisible”, green LED, play melody.

If not divisible: display “No, sum is not a multiple of 3”, red LED, play short buzzer tone.

• Show the message after the number in size 2 font.

LOOP()

• Keep updating the OLED display with the number based on potentiometer.

• When the button is pressed, give feedback with LED and buzzer.