How To Make A Zoetrope Using Arduino | Arduino Project

by | Dec 21, 2022 | Arduino, Basic Coding, Coding

Home » Coding » How To Make A Zoetrope Using Arduino | Arduino Project

Introduction

In this DIY coding tutorial, we will learn how to make a Zoetrope using Arduino. For this Arduino project, we use some still images to make a moving image using a motor. We will use a motor to rotate the still images backward and forward using a circuit.

 

Supplies

In order to make Zoetrope using Arduino, we will require the following components. For physical projects, the components can be bought online or from any electronics shop. For online projects, the TinkerCad website can be used.

Components

Circuit Diagram

Steps To Make A Zoetrope Using Arduino

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

Step 2: Plug the Potentiometer, PushButtons & H – Bridge Motor Driver into the BreadBoard.

Potentiometer:

Step 3: Connect the first Terminal of it to the Ground(GND) pin of the Arduino using a black-colored wire.

Step 4: Connect the wiper terminal of it to the A0 pin of the Arduino Uno.

Step 5: Connect the third terminal of it to the 5V power supply pin of the Arduino Uno.

PushButtons:

Step 6: Connect the 2a terminal of it to the 5V pin of the Arduino.

Step 7: Connect the 1b Terminal of it to the Ground(GND) pin of the Arduino using a black colored wire thru a resistor, as shown in the figure.

Step 8: Connect the 1a terminal of it to the 2 & 3 pin numbers of the Arduino, as shown in the figure.

9V Battery:

Step 9: Connect the negative terminal of it to the GND pin of the Arduino.

H – Bridge Motor Driver:

Step 10: Connect the Power1 terminal of it to the 5V pin of the Arduino.

Step 11: Connect the Power2 terminal of it to the Positive Terminal of the battery.

Step 12: Connect both the Ground terminals of it to the GND pin of the Arduino.

Step 13: Connect both the Output terminals of it to the DC Motor.

Step 14: Connect both the Input Terminals of it to the 9 & 10 number pin of the Arduino, respectively.

Step 15: Connect the Enable 1 & 2 Terminals of it to the 8-number pin of the Arduino.

Source Code

const int inputPin1 = 10;
const int inputPin2 = 9;
const int enablePin = 8;
const int switch1 = 3;
const int switch2 = 2;
const int WiperPin = A0;
int Switch2State = 0;
int previousSwitch2State = 0;
int Switch1State = 0;
int previousSwitch1State = 0;
int motorEnabled = 0;
int motorSpeed = 0;
int motorDirection = 1;
void setup()
{
pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(inputPin1, OUTPUT);
pinMode(inputPin2, OUTPUT);
pinMode(enablePin, OUTPUT);


digitalWrite(enablePin, LOW);
}
void loop()
{
Switch2State = digitalRead(switch2);
delay(1);
Switch1State = digitalRead(switch1);
motorSpeed = analogRead(WiperPin)/4;


if(Switch2State != previousSwitch2State)
{
if(Switch2State == HIGH)
{
motorEnabled = !motorEnabled;
}
}


if(Switch1State != previousSwitch1State)
{
if(Switch1State == HIGH)
{
motorDirection = !motorDirection;
}
}


if(motorDirection == 1)
{
digitalWrite(inputPin1, HIGH);
digitalWrite(inputPin2, LOW);
}
else
{
digitalWrite(inputPin1, LOW);
digitalWrite(inputPin2, HIGH);
}


if (motorEnabled == 1)
{
analogWrite(enablePin, motorSpeed);
}
else
{
analogWrite(enablePin, 0);
}


previousSwitch1State = Switch1State;
previousSwitch2State = Switch2State;
}

Explanation of the Code

1. Initially, we have initialized variables to the pin number to which the terminals of the components are connected to Arduino Uno.

2. After it, we initialized both the switch states to 0. We have also initialized motor variables to 0 for further use in the functions.

3. In the setup function, we have configured the mode of the Arduino pin, whether the pin will be used for input purpose or output purpose. And we are giving Low power to Enable the pin of the H bridge.

4. In the loop function, we are reading the switch input value and storing them in the state variable of it.

5. Then, we use the if statement to fix the Direction of the motor using the switch state value.

6. After fixing the Direction of the motor, we use an if else statement to decide which input pin of the H bridge will get High or low power in order to rotate the DC motor in a particular direction.

7. At last, we display the speed of the motor if the enabled pin’s value is 1.

8. In the end, we are storing the current value of the switch state to its previous value.

Output

How To Make A Zoetrope Using Arduino Arduino Project

On pushing the first button, the motor will rotate in a clockwise direction, and on pushing the second button, the motor will rotate in an anti-clockwise direction. If some still images are attached to it, it will give a fine look of the moving image.

 

 

You May Also Like To Create…