6 Simple Arduino UNO Projects

Arduino UNO is a popular choice among Arduino boards, based on the Atmel ATmega328P microcontroller, suitable for a variety of learning and prototyping applications. In this article, TechSparks will introduce 6 simple Arduino UNO projects suitable for beginners.

Table of Contents

Marquee Lights

The marquee lights project is a straightforward endeavor, achieving a flashing and alternating effect for multiple LED lights in an external circuit by controlling the I/O port of the microcontroller, switching between high and low voltage levels. In this project, we utilize an Arduino UNO to control six LEDs in the external circuit, making them blink at 1-second intervals. Below, you will find the project’s circuit diagram and core code:

Simple marquee project circuit diagram

				
					int startPin = 2;
int numLeds = 6;
int currentIndex = 0;
void setup() {
  // Configure pins as outputs
  for (int i = startPin; i < startPin + numLeds; i++) {
    pinMode(i, OUTPUT);
  }
}
void loop() {
  // Turn off all LED lights
  for (int i = startPin; i < startPin + numLeds; i++) {
    digitalWrite(i, LOW);
  }
  
  // Turn on the next LED light
  digitalWrite(startPin + currentIndex, HIGH);
  
  // Update the index of the current LED, ensuring it loops between 0 and numLeds
  currentIndex = (currentIndex + 1) % numLeds;
  
  // Wait for 1 second
  delay(1000);
}

				
			

Stepper Motor

A stepper motor is a special type of motor that rotates in discrete steps rather than continuously. It is typically digitally controlled, and it rotates a specific angle or takes a step with each pulse it receives. The displacement is directly proportional to the number of pulses, and the speed is proportional to the pulse frequency.

In this project, a five-wire, four-phase stepper motor is used. It consists of four coils, each referred to as a phase, and the motor’s movement is controlled by sequencing these phases. To control it effectively, an ULN2003 stepper motor driver module is used. The module’s IN1 to IN4 pins are connected to the microcontroller’s I/O ports. This module converts digital signals into pulse signals and uses indicator lights to show the stepper motor’s operating state.

Five-wire four-phase stepper motor module

				
					#include <Arduino.h>
#define MOTOR1 8
#define MOTOR2 9
#define MOTOR3 10
#define MOTOR4 11
#define STEPS_PER_REVOLUTION 64
void stepMotor(int thisStep);
void controlStepper(int motorPins[4], int whatSpeed, int steps);
void setup() {
  pinMode(MOTOR1, OUTPUT);
  pinMode(MOTOR2, OUTPUT);
  pinMode(MOTOR3, OUTPUT);
  pinMode(MOTOR4, OUTPUT);
}
void loop() {
  int motorPins[4] = {MOTOR1, MOTOR2, MOTOR3, MOTOR4};
  controlStepper(motorPins, 800, 20);
}
void controlStepper(int motorPins[4], int whatSpeed, int steps) {
  int direction = (steps > 0) ? 1 : 0;
  int stepNumber = 0;
  int stepsLeft = abs(steps);
  unsigned long stepDelay = 60L * 1000L / 64 / whatSpeed;
  long lastStepTime = 0;
  
  while (stepsLeft > 0) {
    if (millis() - lastStepTime >= stepDelay) {
      lastStepTime = millis();
      if (direction == 1) {
        stepNumber++;
        if (stepNumber == STEPS_PER_REVOLUTION) {
          stepNumber = 0;
        }
      } else {
        if (stepNumber == 0) {
          stepNumber = STEPS_PER_REVOLUTION;
        }
        stepNumber--;
      }
      stepsLeft--;
      stepMotor(stepNumber % 8, motorPins);
    }
  }
}
void stepMotor(int thisStep, int motorPins[4]) {
  switch (thisStep) {
    case 0:  // 1000
      digitalWrite(motorPins[0], HIGH);
      digitalWrite(motorPins[1], LOW);
      digitalWrite(motorPins[2], LOW);
      digitalWrite(motorPins[3], LOW);
      break;
    // Add other cases for different step sequences
  }
}

				
			

Ultrasonic Ranging

Ultrasonic” refers to mechanical waves with a vibration frequency higher than 20kHz. It is characterized by its high frequency, short wavelength, minimal diffraction, good directionality, and the ability to propagate directionally. Ultrasonic technology finds widespread applications in various fields, and the HC-SR04 ultrasonic distance sensor module is one of such applications.

This module comprises a sensor for emitting ultrasonic waves and another sensor for receiving the echoes of those waves. The operational principle involves sending a high-level signal, lasting over 10 microseconds, from a control pin of a microcontroller to the module’s trigger pin. This signal is then transmitted as a series of ultrasonic pulses by the sensor. Subsequently, we wait for a high-level response from the echo pin, indicating that the echo has been received. By measuring the time difference between transmission and reception, we can precisely calculate the distance between the sensor and an object.

HC-SR04 ultrasonic distance sensor module

				
					const int trigPin = 3;
const int echoPin = 4;
void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}
void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH, 60000); // Duration of the high-level pulse within 60 seconds
  float cm = (duration / 2) / 29.1; // Calculate distance based on the speed of sound
  Serial.println(cm);
  delay(100);
}
				
			

LCD1602

LCD1602 is a common character-type liquid crystal display module. “1602” indicates that it can display 16 characters in width and has a height of 2 rows. In this project, we use the UNO development board to control the display of desired characters on the LCD screen. By including the <LiquidCrystal.h> library in Arduino, this functionality can be easily implemented. The hardware circuit connections and core code are as follows:

Arduino UNO LCD1602 project wiring

				
					#include <LiquidCrystal.h>
const int Rs = 3, En = 5, D4 = 10, D5 = 11, D6 = 12, D7 = 13;
LiquidCrystal lcd(Rs, En, D4, D5, D6, D7);
void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello Arduino UNO!");
}
void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 1000);
}
				
			

LM35 Temperature Sensor

LM35 is an integrated temperature sensor that outputs the current temperature value in the form of voltage based on the influence of temperature on its internal voltage. It is easy to use and can be directly connected to a microcontroller with just one analog pin to read the sensor’s collected analog value. The actual temperature can then be calculated from this analog value using a specific mathematical formula. The hardware circuit connection diagram and core code are as follows:

arduino uno LM35 temperature sensor project wiring diagram

				
					void loop() {
  // Put your main code here, to run repeatedly:
  Serial.println(analogRead(A0) * 0.49);  // Assuming A0 is connected to the LM35 temperature sensor
  delay(1000);
}

				
			

RFID

This project can utilize an RFID card reader module to identify the content of electronic tags. To achieve this, you need to use the MFRC522 library. The core code is as follows:

				
					#include <MFRC522.h>
#include <SPI.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println("Scan PICC to see UID and type...");
}
void loop() {
  // put your main code here, to run repeatedly:
  if (!mfrc522.PICC_IsNewCardPresent()) // If it's not a new card, return
  {
    return;
  }
  if (!mfrc522.PICC_ReadCardSerial()) // Failed to select the card
  {
    return;
  }
  mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

				
			

More content you may be interested in

How to Enable Multi-Core on ESP32 Microcontroller
How to Enable Multi-Core on ESP32 Microcontroller

This comprehensive guide elucidates the process of enabling multi-core functionality on the ESP32 microcontroller, leveraging its dual-core architecture for enhanced parallel processing capabilities. Through detailed

Arduino MQ-3 Alcohol Sensor Project
Arduino MQ-3 Alcohol Sensor Project

Creating an alcohol sensing project with an MQ-3 sensor and Arduino allows for accurate alcohol concentration monitoring in environments like bars and factories. The MQ-3

Arduino Temperature Alarm Project
Arduino Temperature Alarm Project

This Arduino temperature alarm project effectively demonstrates how to create a practical temperature monitoring system. By utilizing the LM35 temperature sensor and a buzzer, it

Arduino Breathing LED Project
Arduino Breathing LED Project

A breathing light is an LED lighting effect that simulates the human breathing process, gradually increasing or decreasing in brightness within a specific cycle. This

Scroll to Top