In this post, we’ll be using an Arduino UNO R3 to drive a 7 segment display and stepper motor as a sort of “getting started with Arduino.” We’ll also build a small sample program to make the two work together and discuss other general projects that you could build using an Arduino UNO.

Parts list

Getting started

The Elegoo UNO Project Super Starter Kit is a super fun and comprehensive kit that provides everything needed to get started with Arduino programming. The kit comes with a variety of components, including a 4-digit 7-segment display, which can be used for just about anything you’d think up. In this article, for example purposes, I’m going to use it rotate a stepper motor from 0 to 2 radians, and to display the angle of a stepper motor in radians on the display.

The Elegoo UNO Project Super Starter Kit also comes with a comprehensive tutorial book that explains how to use each component in the kit and provides sample code for a variety of projects. This makes it easy for beginners to get started with Arduino programming and quickly build their own projects.

Overall, the Elegoo UNO Project Super Starter Kit with Tutorial and UNO R3 Compatible with Arduino IDE is an excellent choice for anyone looking to get started with Arduino programming and other electronics projects. The included 4-digit 7-segment display and stepper motor, and other included sensors, are powerful tools that can be used to create a wide range of projects and applications.

Let’s get started!

Wiring the stepper motor and display

At a high level, this section will explain of how the wires are wired from the stepper motor driver and stepper motor to the arduino.

The Elegoo UNO Project Super Starter Kit includes a 4 Phase ULN2003 Stepper Motor Driver PCB, which is used to control the stepper motor. To wire the stepper motor driver and stepper motor to the Arduino, the following steps should be taken:

  • Connect the stepper motor to the stepper motor driver by connecting the wires from the stepper motor to the corresponding connectors on the stepper motor driver PCB. The wiring diagram for the stepper motor should be followed to ensure that the wires are connected correctly.
  • Connect the stepper motor driver PCB to the Arduino by connecting the four control pins of the stepper motor driver to the corresponding digital pins on the Arduino. The control pins are usually labeled IN1, IN2, IN3, and IN4 and can be connected to any digital pins on the Arduino. Take note of which digital pins you’re connecting each of these to because it will be important for your code later.
  • Connect the power supply to the stepper motor driver PCB. The stepper motor driver PCB requires a DC power supply of around 12V to function. The power supply should be connected to the +V and GND terminals on the stepper motor driver PCB.
  • Connect the 4-digit 7-segment display to the Arduino. The digital pins of the display should be connected to the corresponding digital pins on the Arduino.
  • Once the stepper motor, stepper motor driver, and 4-digit 7-segment display are connected to the Arduino, the code can be uploaded to control the stepper motor and display the angle in radians on the 4-digit 7-segment display. It is important to note that the ULN2003 Stepper Motor Driver PCB has 4 inputs that are connected to the arduino digital pins and 4 outputs that are connected to the stepper motor.

Now we’re done with the hardware!

Writing the code

This section will describe starting a new project in Arduino IDE and writing the required code to rotate from 0 to 2 radians on the stepper motor while displaying the angle in radians on the 4 digit 7 segment display.

To start a new project in Arduino IDE, the following steps should be taken:

  • Open the Arduino IDE software on your computer.
  • Click on the “File” menu and select “New” to create a new sketch.
  • Give a name to your sketch and save it in a location of your choice.
  • In the Arduino IDE, you will need to import the stepper library by going to the Sketch menu and selecting Include Library, then Stepper. This library contains all the functions needed to control the stepper motor.
  • Next, you need to declare the digital pins on the Arduino that will be connected to the corresponding IN1, IN2, IN3, and IN4 ports on the ULN2003 stepper motor driver PCB.
  • Declare a variable for the stepper motor, using the Stepper class and the number of steps per revolution of your stepper motor.
  • Declare a variable for the stepper motor driver, using the ULN2003Stepper class and the digital pins that you have connected to the IN1, IN2, IN3, and IN4 ports on the stepper motor driver PCB.
  • Next, in the setup() function, initialize the stepper motor by using the stepper.setSpeed() function and specifying the RPM speed you want the motor to rotate at.
  • In the loop() function, you can use the stepper.step(steps) function to rotate the stepper motor from 0 to 2 radians. The steps variable is calculated by multiplying the number of steps per revolution by the angle in radians divided by 2π.
  • To display the angle in radians on the 4-digit 7-segment display, you can use the Arduino digitalWrite() function to send the appropriate signals to the digital pins connected to the display.
  • Finally, you can use the delay() function to add a delay between steps, in order to slow down the rotation of the stepper motor, and make it more visible.
  • Here is an example of the code that could be used to rotate the stepper motor from 0 to 2 radians while displaying the angle in radians on the 4-digit 7-segment display:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <Stepper.h>
#include <ULN2003Stepper.h>

const int stepsPerRevolution = 200;
const int IN1 = 1;
const int IN2 = 2;
const int IN3 = 3;
const int IN4 = 4;
const int display_pin_1 = 5;
const int display_pin_2 = 6;
const int display_pin_3 = 7;
const int display_pin_4 = 8;

ULN2003Stepper stepper(IN1, IN2, IN3, IN4);

void setup() {
stepper.setSpeed(30);
}

void loop() {
for (float angle = 0; angle < 2; angle += 0.01) {
int steps = angle * stepsPerRevolution / (2 * 3.14);
stepper.step(steps);
delay(100);
digitalWrite(display_pin_1, angle / 1000);
digitalWrite(display_pin_2, (angle % 1000) / 100);
digitalWrite(display_pin_3, (angle % 100) / 10);
digitalWrite(display_pin_4, angle % 10);
}
}

The digitalWrite() function is a built-in function in the Arduino programming language that allows you to control the state of a digital pin on the Arduino board. The function takes two arguments: the pin number and the state (HIGH or LOW). When you call digitalWrite(pin, state), it sets the specified pin to the specified state, in this case the corresponding digits.

Additionally, to some readers, the pin assignments between code and the physical Arduino may be confusing. In the Arduino IDE code, the digital pins on the Arduino UNO R3 Controller Board are represented by variables. These variables can be used in the code to refer to the specific digital pin that is being used. For example, if you want to use digital pin 13 to control an LED, you would use the variable “13” in the code to refer to that pin. It’s important to note that the mapping of the physical pins to the variables in the code is not arbitrary, the mapping is fixed and you can check it on the arduino board itself or on the official documentation.

Let’s get running

Lastly, we need to hook our computer up to the Arduino, stepper motor, and 7 segment display, run the code, and see our results. Here’s how we do that:

To hook up the Arduino UNO R3 Controller Board to a computer to upload code to the device, the following steps should be taken:

  • Connect the Arduino UNO R3 Controller Board to the computer using a USB cable. The USB cable should be connected to the USB connector on the Arduino board and the USB port on the computer.
  • Install the Arduino IDE software on your computer if it is not already installed. You can download the latest version of the Arduino IDE from the official Arduino website.
  • Open the Arduino IDE software on your computer and select the appropriate board and port from the “Tools” menu. In the board menu, select Arduino/Genuino Uno, and in the port menu, select the port that your Arduino is connected to.
  • Write or open the code you want to upload to the Arduino board in the Arduino IDE.
  • Verify the code by clicking the “Verify” button, this will check the code for any errors.
  • Upload the code to the Arduino board by clicking the “Upload” button. This will transfer the code from the computer to the Arduino board.
  • The upload process may take a few seconds, wait until the upload is complete and the message “Done uploading” appears on the Arduino IDE.
  • Once the code has been uploaded to the Arduino board, it will automatically begin running on the device. You should hear your motor begin rotating and you should see the digits change on the display.

It’s important to note that the Arduino board needs to be connected to the computer while uploading the code, and it’s also important to make sure that the board and the port are correctly selected in the Arduino IDE before uploading the code.

Next steps

You didn’t come here just to build a toy that rotates from 0 to 2 radians. Use your new found knowledge to modify the code to do other stuff, or do some other interesting projects with your kit:

  • Add a potentiometer to the circuit to allow the user to control the rotation speed of the stepper motor. This can be done by connecting the potentiometer to an analog pin on the Arduino board and using the analogRead() function to read the value of the potentiometer.
  • Add an ultrasonic sensor to the circuit to allow the user to control the rotation of the stepper motor based on the distance detected by the sensor. This can be done by connecting the ultrasonic sensor to the digital pins on the Arduino board and using the pulseIn() function to measure the duration of the ultrasonic pulse.
  • Add a Bluetooth module to the circuit to allow the user to remotely control the rotation of the stepper motor. This can be done by connecting the Bluetooth module to the digital pins on the Arduino board and using the SoftwareSerial library to communicate with the module.
  • Add a OLED display module to the circuit to display more information such as current angle, rotation speed, or total rotation time. This can be done by connecting the OLED display module to the digital pins on the Arduino board and using the Adafruit_SSD1306 and Adafruit_GFX libraries to control the display.
  • Add a real-time clock module to the circuit to display the current time on the 4 digit 7 segment display. This can be done by connecting the real-time clock module to the digital pins on the Arduino board and using the RTClib library to communicate with the module.

Thank you for reading the article on using the Elegoo UNO Project Super Starter Kit with Tutorial and UNO R3 Compatible with Arduino IDE. I hope that this article was helpful in providing an overview of the features and capabilities of the kit and how to use it to build a simple project.

I encourage you to experiment with the kit and see what you can create. If you used the kit to build something, please leave a comment below and let me know what you built and how it turned out. I would love to hear about your experiences and see your creations.

The Elegoo UNO Project Super Starter Kit is a great way to learn about the basics of arduino programming and electronics in general. It’s a great tool to get started on your journey to become a maker, and as you can see, there’s plenty of room for modifications and improvements to the projects that come with the kit.

I wish you the best in your future projects and please don’t hesitate to reach out if you have any questions or need help.

Did you enjoy my post?

I'm really excited about the work that I'm doing here. If you enjoyed my post and my work, please consider tipping me with a coffee. I appreciate you taking the time to read my post!

Comments

2023-01-12

⬆︎top