A collection of standalone Arduino-based mini-projects demonstrating core embedded communication protocols (I2C, SPI, UART) and peripheral integrations (Stepper Motor, Rotary Encoder, IMU). Each project includes schematics, pin configurations, and tested Arduino code to help you learn and prototype quickly.
-
Download and install the latest Arduino IDE from the official website:
https://www.arduino.cc/en/software -
Install required libraries (if any) via Arduino Library Manager or GitHub:
- SparkFun MPU9250 DMP:
https://github.com/sparkfun/SparkFun_MPU9250_DMP_Arduino_Library
- SparkFun MPU9250 DMP:
Product | Description | Official Link |
---|---|---|
Arduino UNO/Mega | Microcontroller Board | Arduino UNO |
MPU-9250 | 9-DoF IMU Sensor | MPU-9250 |
Stepper Motor | Stepper Motor Driver | A4988 Stepper Drive |
Rotary Encoder | Incremental Rotary Encoder | Rotary Encoder |
Each project contains:
- Pinout diagram
- Pin configuration
- Code folder link
This project demonstrates I2C communication where the Master requests data from the Slave, and the Slave transmits data back.
Pin | Function | Connection |
---|---|---|
A4 | SDA (Data) | Connect SDA pins of Master & Slave |
A5 | SCL (Clock) | Connect SCL pins of Master & Slave |
GND | Ground | Common Ground |
5V | Power | Match board voltage |
- The Master Arduino sends a request to the Slave for data.
- The Slave Arduino responds by transmitting the requested data.
- The Master receives and prints the data on its Serial Monitor.
- Communication runs smoothly at 100 kHz (standard I2C speed).
This project demonstrates I2C communication where the Master transmits data to the Slave, and the Slave receives it.
Pin | Function | Connection |
---|---|---|
A4 | SDA (Data) | Connect SDA pins of Master & Slave |
A5 | SCL (Clock) | Connect SCL pins of Master & Slave |
GND | Ground | Common Ground |
5V | Power | Match board voltage |
- The Master Arduino continuously sends data to the Slave.
- The Slave Arduino receives the transmitted data and prints it on its Serial Monitor.
- Data transmission occurs reliably without loss or errors.
- Communication speed is set to standard I2C frequency.
This project demonstrates SPI communication between two Arduino boards:
- One configured as the Master to transmit data.
- One configured as the Slave to receive and display the data.
Pin | Function | Master Arduino | Slave Arduino |
---|---|---|---|
11 | MOSI (Master Out, Slave In) | β Connects to Slave's MOSI | β Receives from Master's MOSI |
12 | MISO (Master In, Slave Out) | β Connects to Slave's MISO | β Sends to Master's MISO |
13 | SCK (Clock) | β Drives Clock | β Receives Clock |
10 | SS (Slave Select) | β Pull LOW to select | Input - Chip Select |
GND | Ground | β Common Ground | β Common Ground |
5V | Power (if needed) | Shared if same board voltage | Shared if same board voltage |
β οΈ Connect MOSI to MOSI, MISO to MISO, SCK to SCK, and ensure common GND between devices.
- Master:
SPI_MASTER/SPI_MASTER.ino
- Slave:
SPI_SLAVE/SPI_SLAVE.ino
- The Master sends incrementing integer data over SPI every 2 seconds.
- The Slave receives and prints the transmitted value via Serial Monitor.
This project demonstrates UART communication between two Arduino boards, where one transmits integer data and the other receives and prints it.
Pin | Function | Transmitter Connection | Receiver Connection |
---|---|---|---|
D1 | TX | β RX of Receiver (D0) | |
D0 | RX | β TX of Transmitter (D1) | |
GND | Ground | β Common Ground | β Common Ground |
β οΈ Make sure both Arduino boards share a common ground for UART to work correctly.
- Transmitter:
UART_transmit_integer/transmit_integer.ino
- Receiver:
UART_receive_integer/receive_integer.ino
- The transmitter continuously sends an increasing integer value every second.
- The receiver reads the integer via UART and prints it to the serial monitor.
This project controls a NEMA17 stepper motor using a simple step and direction interface.
The motor rotates to a specified angle in the clockwise direction and then reverses to the same angle in the counter-clockwise direction using digital pulses.
π The code assumes a stepper driver (e.g., A4988 or DRV8825) connected to the Arduino.
Adjust steps per revolution in code if using a different motor or driver microstepping mode.
Pin | Function | Description |
---|---|---|
3 | STEP | Pulse to step motor |
4 | DIR | Direction of rotation |
GND | Ground | Common ground |
5V | Power | Motor driver logic supply |
- On power-up, the motor:
- Rotates 90 degrees clockwise
- Waits for 2 seconds
- Rotates 90 degrees counter-clockwise
- Waits for 2 seconds
- This cycle repeats continuously.
This project reads the analog signal from a Pankaj Rotary Encoder (analog-type) to estimate the direction and amount of rotation.
β οΈ This is not a typical quadrature encoder. It outputs analog voltages which are used to determine relative movement.
Pin | Function | Description |
---|---|---|
A0 | Analog output | Reads voltage change from encoder |
GND | Ground | Common ground |
5V | Power | Sensor power supply |
- The code continuously monitors changes in analog voltage on A0.
- It compares current and previous values to:
- Increment a counter when turned clockwise
- Decrement the counter when turned counter-clockwise
- Output is printed to Serial Monitor as position updates (
disp1
).
This project demonstrates integration of the SparkFun MPU9250 IMU sensor using the DMP (Digital Motion Processor) feature for real-time orientation tracking.
Pin | Function | Description |
---|---|---|
A4 | SDA | I2C Data Line |
A5 | SCL | I2C Clock Line |
3.3V | Power | Sensor power supply (3.3V) |
GND | Ground | Common ground |
- The MPU9250 sensor initializes and starts its onboard DMP.
- The sensor calculates quaternion data representing 3D orientation.
- The Arduino reads and processes quaternion to compute yaw, pitch, and roll.
- Yaw values are sent over Serial1.
- The Serial Monitor displays debug info, and orientation data can be used for motion tracking applications.
- Always ensure common ground between boards.
- Match power voltage levels across devices.
- Refer to respective folder for full code and comments.
Happy Coding!