Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

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

View and Edit Project In Cirkit DesignerImage 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

L298N DC Motor Driver

DC Motor (First Unit)

DC Motor (Second Unit)

4 x AAA Battery Mount

Rain/Snow Sensor - Board

YL-83 Rain Sensor - Detection Board

OLED 1.3" Display

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