5 Arduino Uno Projects with Code You Can Simulate Online

Description:
Dive into the world of Arduino with these five beginner-friendly projects that you can simulate online! From controlling LED brightness and counting numbers on a 7-segment display to measuring signal frequency with an LCD, these hands-on tutorials are perfect for electronics enthusiasts and aspiring makers. Each project is explained step-by-step, complete with detailed code and descriptions, making it easier than ever to learn Arduino programming and circuit design. Whether you're exploring shift registers, PWM, or LCD interfacing, these projects will help you build your skills and inspire your next creation. Perfect for beginners eager to experiment and learn!

Arduino UNO 7 Segment Display using a register shifter

Shift schematic

This Arduino code demonstrates how to control two 7-segment displays efficiently using a shift register, reducing the number of required output pins. The program communicates with the shift register through three defined pins: dataPin (A5), clockPin (A4), and resetPin (A3). The numbers array contains the byte representations of digits 0 through 9, which are used to illuminate the appropriate segments on each display.

In the setup() function, the data, clock, and reset pins are initialized as outputs to communicate with the shift register. The loop() function cycles through the digits 0 to 9, displaying each number on the first 7-segment display while simultaneously showing the subsequent number on the second display. This creates a dynamic counting effect across both displays. The displayNumber() function is responsible for resetting the shift register and sending the correct data to each display, ensuring accurate representation of the digits. The shiftOut() function handles the actual transfer of data bits to the shift register, activating the specific segments needed to display each digit.

This project serves as an excellent introduction to using shift registers for efficient digital output control. It provides a practical and hands-on way for beginners to learn about reducing pin usage, interfacing 7-segment displays, and managing data flow in Arduino-based electronics projects. It’s a fun and educational way to explore key concepts in embedded systems and digital electronics.

// Define pins
const int dataPin = A5; // The D1 pin of the shift register is connected to pin A5 of the Arduino
const int clockPin = A4; // The clock input pin of the shift register is connected to pin A4 of the Arduino
const int resetPin = A3; // The reset pin of the shift register is connected to pin A3 of the Arduino

// Common cathode 7-segment display characters
byte numbers[] = {
0x3F, // 0
0x06, // 1
0x5B, // 2
0x4F, // 3
0x66, // 4
0x6D, // 5
0x7D, // 6
0x07, // 7
0x7F, // 8
0x6F // 9
};

void setup() {
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(resetPin, OUTPUT);
}

void loop() {
for (int i = 0; i < 10; i++) {
displayNumber(i, (i + 1) % 10);
delay(1000);
}
}

void displayNumber(int num1, int num2) {
digitalWrite(resetPin, LOW); // Reset shift register
digitalWrite(resetPin, HIGH);

//Send data to the first 7-segment display
shiftOut(dataPin, clockPin, MSBFIRST, numbers[num1]);

// Send data to the second 7-segment display
shiftOut(dataPin, clockPin, MSBFIRST, numbers[num2]);
}

void shiftOut(int value) {
for (int i = 0; i < 8; i++) {
digitalWrite(dataPin, (value & (1 << (7 - i))) ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}

Frequency counter Arduino UNO

Frequency counter

This Arduino code showcases how to measure and display the frequency of a digital signal using a Liquid Crystal Display (LCD). The program leverages the LiquidCrystal library to handle LCD functionality, initializing it with predefined pins for communication. The primary task is to measure the frequency of a signal connected to the signalPin (A0) by counting the incoming pulses and calculating their timing.

In the setup() function, the signal pin is configured as an input to detect the digital signal's pulses, and the LCD is initialized to display a static label on the first row, indicating that it will show frequency measurements. The loop() function continuously monitors the state of the signal pin. When a HIGH signal is detected, the program records the pulse's start time. Once the signal transitions to LOW, the pulse's duration is calculated, and the pulse count is incremented. Using this data, the frequency of the signal is computed in Hertz (Hz) and displayed dynamically on the second row of the LCD.

This project is an excellent introduction to frequency measurement, LCD interfacing, and timing in Arduino programming. It gives electronics enthusiasts a hands-on opportunity to explore practical applications like pulse counting and signal analysis. Perfect for beginners, this project combines theory and practice to build foundational skills in embedded systems and signal processing.

#include <LiquidCrystal.h>

// Initialize the LCD object with the Arduino pins used for communication
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

// Define the input pin for the signal
const int signalPin = A0;

// Variables to track pulse timing, count, and calculated frequency
unsigned long pulseStartTime = 0; // Stores the start time of the current pulse
unsigned long pulseCount = 0; // Counts the number of pulses detected
float frequency = 0.0; // Stores the calculated frequency in Hz

void setup() {
// Configure the signal pin as an input to detect pulses
pinMode(signalPin, INPUT);

// Initialize the LCD with 16 columns and 2 rows
lcd.begin(16, 2);

// Display a static label on the LCD to indicate the frequency
lcd.print("Frequency(Hz):");
}

void loop() {
// Check if the signal pin is HIGH (start of a pulse)
if (digitalRead(signalPin) == HIGH) {
// If this is the start of a new pulse, record the time
if (pulseStartTime == 0) {
pulseStartTime = millis();
}
} else {
// Check if the pulse has ended
if (pulseStartTime != 0) {
// Increment the pulse count
pulseCount++;

  // Calculate the duration of the pulse (in milliseconds)
  unsigned long pulseDuration = millis() - pulseStartTime;

  // Calculate the frequency in Hz
  // Frequency = 1000 ms / average pulse duration
  frequency = 1000.0 / (pulseDuration / (pulseCount - 1));

  // Reset the pulse start time for the next pulse
  pulseStartTime = 0;
}
}

// Move the cursor to the second row, column 9 on the LCD
lcd.setCursor(9, 1);

// Display the calculated frequency with 4 decimal places
lcd.print(frequency, 4);

// Add a short delay to stabilize the display updates
delay(100); // Changed to 100 ms for readability }


Simple Arduino UNO counter

Project 3 schematic

This Arduino code provides an interactive way to control a 7-segment display, allowing users to cycle through numbers 0 to 9 using a button press. The segmentPins array specifies the Arduino pins connected to each segment of the display, while the buttonPin variable is assigned to an analog pin that monitors the button's state. Additionally, the numbers array stores the byte representations of digits 0 through 9, which determine which segments are activated to display the corresponding numbers.

During the setup() function, the segment pins are initialized as outputs, and the button pin is configured as an input. The loop() function continuously monitors the button's state to detect presses. When a button press is registered, the displayNumber() function is called to illuminate the appropriate segments on the 7-segment display, showing the current counter value. The counter increments with each press and resets to 0 once it surpasses 9, creating a seamless counting system.

This project is an excellent starting point for beginners exploring Arduino programming, interfacing with 7-segment displays, and handling button inputs. It provides a straightforward yet rewarding introduction to these essential concepts, offering hobbyists a fun and educational hands-on experience in electronics and coding.

int segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
int buttonPins = A0;

byte numbers[10] = {
0x3F, // 0
0x06, // 1
0x5B, // 2
0x4F, // 3
0x66, // 4
0x6D, // 5
0x7D, // 6
0x07, // 7
0x7F, // 8
0x6F // 9
};

int counter = 0;

void setup() {
for (int i = 0; i < 7; i++) {
pinMode(segmentPins[i], OUTPUT);
}
pinMode(buttonPins, INPUT);
}

void loop() {
if(digitalRead(buttonPins) == HIGH){
displayNumber(counter);
counter = (counter + 1) % 10;
delay(1000);
}
}

void displayNumber(int num) {
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], numbers[num] & (1 << i));
}
}

Arduino UNO multiples of 3 project for beginners

Schematic of the 4 project

This beginner-friendly Arduino Uno project combines a Liquid Crystal Display (LCD) and an LED to create a simple yet engaging embedded electronics demonstration. The program counts from 1 to 100 on the LCD while controlling an LED, making it a great way to learn about interfacing and control with Arduino. Additionally, the project includes a welcoming message encouraging users to subscribe to the YouTube channel Easy Electronics for more tutorials on embedded systems.

In the setup() function, the LCD is initialized for a 16x2 display, and an introductory message is displayed to greet the user. The loop() function handles the counting logic, incrementing numbers from 1 to 100 and updating the LCD in real time. As an added feature, every time the count reaches a multiple of 3, the LED connected to pin 13 blinks for one second, providing visual feedback alongside the display. Once the counting is complete, the LCD shows the final count and the total number of LED blinks.

This project is an excellent introduction to working with LCDs, controlling LEDs, and understanding basic Arduino programming concepts. By combining these components, it offers a hands-on opportunity for beginners to build an interactive and practical circuit, sparking curiosity and enthusiasm for embedded electronics.

Code:

#include<LiquidCrystal.h>

// visit my channel for embedded electronics tutorials: https://www.youtube.com/@EasyElectronics2
// Initialize the LCD, setting the pins connected to the LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2, 10, 9, 8, 7);
// Define the LED pin
const int ledPin = 13;
// Define the LED blink counter
int ledBlinks = 0;

void setup() {
// Initialize the LCD display
lcd.begin(16, 2);
// Initialize the LED pin as output mode
lcd.print("Subscribe!!");
delay(1000);
pinMode(ledPin, OUTPUT);
// Clear the LCD display
lcd.clear();
// Display initial message
lcd.print("Counting to 100…");
}

void loop() {
for (int count = 1; count <= 100; count++) {
// Each time the counter is incremented, display it on the LCD
lcd.clear(); // Clear the LCD display
lcd.setCursor(0, 0);
lcd.print("Count: ");
lcd.print(count);

// Check if the count is a multiple of 3
if (count % 3 == 0) {
  // Turn on the LED
  digitalWrite(ledPin, HIGH);
  // Wait for one second so you can see the LED light up
  delay(1000);
  // Turn off the LED
  digitalWrite(ledPin, LOW);
  // Increment the LED blink counter
  ledBlinks++;
}

// Wait a bit before continuing to count so you can read the numbers on the LCD
delay(1000);
}

// After counting, display the final message
lcd.clear();
lcd.print("Done! Counted to 100");
lcd.setCursor(0, 1); // Move the cursor to the second line
lcd.print("LED Blinks: ");
lcd.print(ledBlinks);

// Stop the program
while (true);
}

Make your own potentiometer with Arduino UNO 

This Arduino code provides an intuitive way to control the brightness of an LED using a potentiometer. The potentiometer is wired to analog pin A0, acting as the input device, while the LED is connected to digital pin 6 as the output. By reading the analog value from the potentiometer (ranging from 0 to 1023), the program maps this input to a corresponding value between 0 and 255. This mapped range aligns with the requirements of the analogWrite() function, which uses Pulse Width Modulation (PWM) to control the LED's brightness—where 0 represents the LED being completely off, and 255 signifies maximum brightness.

In the setup() function, the LED pin is initialized as an output, preparing it for signal control. The loop() function handles the core operation by continuously reading the potentiometer's input, mapping it to the correct brightness range, and adjusting the LED's brightness via PWM. To ensure smoother operation and prevent excessive processor usage, a brief delay is incorporated after each reading.

This project serves as a perfect introduction to working with analog inputs and PWM in Arduino. It offers a hands-on opportunity for beginners to explore foundational concepts in electronics and programming while building a practical and interactive circuit.

schematic:

Schematic of the 5 project

int led_pin = 6; // Define the pin number connected to the LED
int pot_pin = A0; // Define the pin number connected to the potentiometer
int output; // Variable to store the raw analog reading from the potentiometer
int led_value; // Variable to store the mapped LED brightness value

void setup() {
pinMode(led_pin, OUTPUT); // Set the LED pin as an output
}

void loop() {
// Reading the potentiometer value (ranges from 0 to 1023)
output = analogRead(pot_pin);

// Mapping the potentiometer value from the range 0-1023 to 0-255
// because analogWrite can only accept values from 0 (off) to 255 (full brightness)
led_value = map(output, 0, 1023, 0, 255);

// Set the LED brightness using PWM (Pulse Width Modulation)
analogWrite(led_pin, led_value);

// A small delay to avoid overloading the processor
delay(1);
}

Comments