Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Uno-Based Rain-Sensing Robot with OLED Display and Battery Power

Image of Arduino Uno-Based Rain-Sensing Robot with OLED Display and Battery Power

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control two DC motors using an Arduino Uno R3, an L298N DC motor driver, and a rain/snow sensor. The circuit also includes an OLED display for visual feedback. The Arduino Uno R3 serves as the main microcontroller, interfacing with the motor driver, sensor, and display.

Component List

  1. Arduino Uno R3

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: USB Port, Power Jack, Not Connected, IOREF, RESET, 3.3V, 5V, GND, VIN, A0, A1, A2, A3, A4/SDA, A5/SCL, SCL, SDA, AREF, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
  2. L298N DC Motor Driver

    • Description: A dual H-Bridge motor driver module.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  3. DC Motor (2 units)

    • Description: Standard DC motors.
    • Pins: pin 1, pin 2
  4. 4 x AAA Battery Mount

    • Description: Battery holder for four AAA batteries.
    • Pins: -, +
  5. Rain/Snow Sensor - Board

    • Description: A sensor board to detect rain or snow.
    • Pins: 1, 2, A0 (Analog), D0 (Digital), GND, VCC (5V)
  6. YL-83 Rain Sensor - Detection Board

    • Description: Detection board for the rain/snow sensor.
    • Pins: POS, NEG
  7. OLED 1.3" Display

    • Description: A small OLED display for visual feedback.
    • Pins: GND, VCC, SCL, SDA

Wiring Details

Arduino Uno R3

  • 5V: Connected to the 5V pin of the L298N DC motor driver, VCC (5V) pin of the Rain/Snow Sensor - Board, and VCC pin of the OLED 1.3" Display.
  • GND: Connected to the GND pin of the L298N DC motor driver, GND pin of the Rain/Snow Sensor - Board, GND pin of the OLED 1.3" Display, and - pin of the 4 x AAA Battery Mount.
  • A4/SDA: Connected to the SCL pin of the OLED 1.3" Display.
  • A5/SCL: Connected to the SDA pin of the OLED 1.3" Display.
  • Pin 6: Connected to the IN4 pin of the L298N DC motor driver.
  • Pin 5: Connected to the IN3 pin of the L298N DC motor driver.
  • Pin 4: Connected to the IN2 pin of the L298N DC motor driver.
  • Pin 3: Connected to the IN1 pin of the L298N DC motor driver.
  • Pin 2: Connected to the D0 (Digital) pin of the Rain/Snow Sensor - Board.

L298N DC Motor Driver

  • 5V: Connected to the 5V pin of the Arduino Uno R3.
  • GND: Connected to the GND pin of the Arduino Uno R3.
  • IN4: Connected to pin 6 of the Arduino Uno R3.
  • IN3: Connected to pin 5 of the Arduino Uno R3.
  • IN2: Connected to pin 4 of the Arduino Uno R3.
  • IN1: Connected to pin 3 of the Arduino Uno R3.
  • OUT1: Connected to pin 2 of the first DC Motor.
  • OUT2: Connected to pin 1 of the first DC Motor.
  • OUT3: Connected to pin 2 of the second DC Motor.
  • OUT4: Connected to pin 1 of the second DC Motor.
  • 12V: Connected to the + pin of the 4 x AAA Battery Mount.

DC Motor (First Unit)

  • pin 1: Connected to OUT2 of the L298N DC motor driver.
  • pin 2: Connected to OUT1 of the L298N DC motor driver.

DC Motor (Second Unit)

  • pin 1: Connected to OUT4 of the L298N DC motor driver.
  • pin 2: Connected to OUT3 of the L298N DC motor driver.

4 x AAA Battery Mount

  • -: Connected to the GND pin of the Arduino Uno R3.
  • +: Connected to the 12V pin of the L298N DC motor driver.

Rain/Snow Sensor - Board

  • VCC (5V): Connected to the 5V pin of the Arduino Uno R3.
  • GND: Connected to the GND pin of the Arduino Uno R3.
  • D0 (Digital): Connected to pin 2 of the Arduino Uno R3.
  • Pin 1: Connected to the NEG pin of the YL-83 Rain Sensor - Detection Board.
  • Pin 2: Connected to the POS pin of the YL-83 Rain Sensor - Detection Board.

YL-83 Rain Sensor - Detection Board

  • POS: Connected to pin 2 of the Rain/Snow Sensor - Board.
  • NEG: Connected to pin 1 of the Rain/Snow Sensor - Board.

OLED 1.3" Display

  • VCC: Connected to the 5V pin of the Arduino Uno R3.
  • GND: Connected to the GND pin of the Arduino Uno R3.
  • SCL: Connected to the A4/SDA pin of the Arduino Uno R3.
  • SDA: Connected to the A5/SCL pin of the Arduino Uno R3.

Code Documentation

Arduino Uno R3 Code

char t;

void setup() {
  pinMode(13, OUTPUT);   // left motors forward
  pinMode(12, OUTPUT);   // left motors reverse
  pinMode(11, OUTPUT);   // right motors forward
  pinMode(10, OUTPUT);   // right motors reverse
  pinMode(9, OUTPUT);    // LED
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    t = Serial.read();
    Serial.println(t);
  }

  if (t == 'F') {            // move forward (all motors rotate in forward direction)
    digitalWrite(13, HIGH);
    digitalWrite(11, HIGH);
  } else if (t == 'B') {     // move reverse (all motors rotate in reverse direction)
    digitalWrite(12, HIGH);
    digitalWrite(10, HIGH);
  } else if (t == 'L') {     // turn right (left side motors rotate in forward direction, right side motors don't rotate)
    digitalWrite(11, HIGH);
  } else if (t == 'R') {     // turn left (right side motors rotate in forward direction, left side motors don't rotate)
    digitalWrite(13, HIGH);
  } else if (t == 'W') {     // turn LED on
    digitalWrite(9, HIGH);
  } else if (t == 'w') {     // turn LED off
    digitalWrite(9, LOW);
  } else if (t == 'S') {     // STOP (all motors stop)
    digitalWrite(13, LOW);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
  }
  delay(100);
}

Additional Documentation

char t;

void setup() {
  pinMode(13, OUTPUT);   // left motors forward
  pinMode(12, OUTPUT);   // left motors reverse
  pinMode(11, OUTPUT);   // right motors forward
  pinMode(10, OUTPUT);   // right motors reverse
  pinMode(9, OUTPUT);    // LED
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    t = Serial.read();
    Serial.println(t);
  }

  if (t == 'F') {            // move forward (all motors rotate in forward direction)
    digitalWrite(13, HIGH);
    digitalWrite(11, HIGH);
  } else if (t == 'B') {     // move reverse (all motors rotate in reverse direction)
    digitalWrite(12, HIGH);
    digitalWrite(10, HIGH);
  } else if (t == 'L') {     // turn right (left side motors rotate in forward direction, right side motors don't rotate)
    digitalWrite(11, HIGH);
  } else if (t == 'R') {     // turn