Arduino Uno Layout, Introduction and Sensors PDF

Document Details

PleasedSavannah

Uploaded by PleasedSavannah

MAP Department | Eulogio 'Amang' Rodriguez Institute of Science and Technology

Tags

microbots arduino robotics electronics

Summary

This document provides a comprehensive introduction to microbots and their use cases, along with information on how Arduino can be utilized in their development. It also covers basic Arduino concepts and programming, making it suitable for educational and learning purposes.

Full Transcript

**Arduino Uno Layout Pin** **Introduction** Microbots, or microrobots, are miniature robots designed to perform tasks in small, precise, and often challenging environments where larger robots or human intervention is impractical. These tiny machines, typically measured in millimeters or even micro...

**Arduino Uno Layout Pin** **Introduction** Microbots, or microrobots, are miniature robots designed to perform tasks in small, precise, and often challenging environments where larger robots or human intervention is impractical. These tiny machines, typically measured in millimeters or even micrometers, are engineered for applications that demand high precision and minimal invasiveness, such as medical procedures, environmental monitoring, and complex assembly tasks in tight spaces. Due to their size and versatility, microbots are gaining traction in fields ranging from healthcare---where they can navigate inside the human body for targeted drug delivery or diagnostics---to disaster response, where they access confined or hazardous areas to aid in search-and-rescue operations. Microbotics leverages advancements in robotics, materials science, and micro-engineering, allowing these small-scale devices to navigate, sense, and interact with their surroundings effectively. The increasing accessibility of prototyping tools, such as Arduino, has made microbotics an exciting area for research, innovation, and education, enabling students and engineers alike to explore the potential of these micro-scale robots in solving real-world challenges. 1\. What is a Microbot? A microbot is a compact robot designed for tasks where precision, size, and adaptability are essential. These robots are often designed for autonomous operation with minimal intervention. Explain microbots\' small-scale nature, typically ranging from millimeters to centimeters, distinguishing them from standard robots in terms of size and power consumption. Characteristics: Low power consumption, minimal weight, modularity, and ability to navigate confined spaces. Applications of Microbots: Medical Applications: Tiny bots for targeted drug delivery, internal imaging, and minimally invasive procedures. Environmental Monitoring: Deploying small bots to assess water or air quality in inaccessible areas. Search-and-Rescue Operations: Microbots can enter collapsed buildings or dangerous environments to locate victims and assess conditions. Agriculture and Inspection: Used for soil analysis, crop monitoring, or equipment inspection. Examples of Microbot Projects and Current Use Cases: Harvard's RoboBee: Mimics a bee's movement for applications in agriculture and environmental monitoring. MicroScouts: Autonomous, collaborative microbots designed for obstacle navigation and complex terrain exploration. Swarming Drones: Used in search-and-rescue missions, they cover large areas by acting as a coordinated group of microbots. Classroom Idea: Have students brainstorm how a microbot could be designed to navigate and complete a simple task, like finding and marking specific locations in a room. 2\. Why Arduino for Microbotics? Arduino as a Platform: Explain that Arduino is a flexible, open-source platform with a straightforward interface and an extensive library of resources, making it ideal for prototyping microbots. Arduino's versatility means that it can be used for many applications beyond microbotics, but its low cost and ease of programming make it especially valuable in small-scale, educational projects. Hardware Components of Arduino: Microcontroller (ATmega328P): Acts as the bot\'s \"brain,\" controlling sensors and actuators based on coded instructions. Digital and Analog Pins: Provide input and output interfaces for components. PWM Pins: Control motor speed and LED brightness through pulse width modulation. Power Supply Options: USB and battery options for portability; important in microbot applications where mobility is essential. Software Setup and Coding Basics: Arduino IDE: Walk through downloading, installing, and setting up the Arduino IDE on student laptops. Hello World Program: Blink Example: Code a simple blink program to introduce students to the coding structure in Arduino (setup and loop functions). Explanation: Cover basic coding concepts such as variables, delays, and digitalWrite. void setup() { pinMode(13, OUTPUT); // Sets pin 13 as an output pin } void loop() { digitalWrite(13, HIGH); // Turn LED on delay(1000); // Wait 1 second digitalWrite(13, LOW); // Turn LED off delay(1000); // Wait 1 second } Use this code to show students the power of Arduino in automating simple tasks and introduce debugging techniques. 3\. Core Concepts for Microbots Control Structures and Programming Fundamentals: Loops and Conditionals: Use loops (e.g., for loops) and conditionals (if statements) to program repeated actions and decision-making in microbot behavior. Functions: Organize code into reusable functions, an essential skill for structuring complex bot behaviors. Electronics Basics and Circuit Building: Voltage, Current, and Resistance: Quick refresher on Ohm's law and why understanding these basics is key to selecting appropriate components. Breadboarding: Practice setting up simple circuits using breadboards to connect sensors and motors. Example Activity: Create a circuit to control an LED using a switch, introducing the concept of input/output circuits. Sensors and Actuators for Microbots: Sensors (Ultrasonic, Infrared, Gyroscope): Discuss sensors commonly used for detecting obstacles, motion, or orientation. Code Example: Introduce the NewPing library for using ultrasonic sensors to measure distance. \#include \ \#define TRIG\_PIN 12 \#define ECHO\_PIN 11 \#define MAX\_DISTANCE 200 NewPing sonar(TRIG\_PIN, ECHO\_PIN, MAX\_DISTANCE); void setup() { Serial.begin(9600); } void loop() { int distance = sonar.ping\_cm(); Serial.print(\"Distance: \"); Serial.print(distance); Serial.println(\"cm\"); delay(100); } Motors (DC Motors, Servo Motors): Use motors for microbot movement and orientation. Example Code: Control servo motor angles using Servo.h. \#include \ Servo myServo; int pos = 0; void setup() { myServo.attach(9); } void loop() { for (pos = 0; pos \= 0; pos -= 1) { myServo.write(pos); delay(15); } } 4\. Practical Activity: Building a Line-Following Microbot Objective: Use sensors and motors to build a line-following bot. Materials: Arduino board, line sensors (IR or photoreflective), DC motors, wheels, and a chassis. Assembly: Guide students through assembling the bot, explaining each component's purpose. Programming: Teach students to read sensor input, make conditional decisions (turn left, right, forward), and control motor outputs based on sensor data. Testing and Debugging: Encourage students to troubleshoot common issues, such as sensor calibration and motor speed adjustments. 5\. Advanced Topics (for Further Exploration) Wireless Communication: Discuss Bluetooth and Wi-Fi modules for remote control. Power Management: Explain battery selection based on voltage and capacity needs. Advanced Control (PID Control): Introduce proportional-integral-derivative control for smooth movement, explaining how it helps maintain steady movement by adjusting motor speeds based on error calculations. **Example of Sensor and Pin Layout and code** 1\. Ultrasonic Sensor (HC-SR04) Function: Measures distance by emitting and receiving sound waves. Pins: VCC: Connect to Arduino 5V. GND: Connect to Ground. TRIG: Trigger pin for sending an ultrasonic pulse (connect to a digital pin, e.g., pin 9). ECHO: Echo pin for receiving the pulse (connect to a digital pin, e.g., pin 10). Code Example: const int trigPin = 9; const int echoPin = 10; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(9600); } void loop() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration \* 0.034 / 2; Serial.print(\"Distance: \"); Serial.print(distance); Serial.println(\" cm\"); delay(500); } 2\. Temperature and Humidity Sensor (DHT11) Function: Measures temperature and humidity levels. Pins: VCC: Connect to 5V. GND: Connect to Ground. DATA: Output data pin (connect to a digital pin, e.g., pin 2). Code Example: Requires the DHT library (install from Arduino Library Manager). \#include \ \#define DHTPIN 2 \#define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); } void loop() { float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); if (isnan(humidity) \|\| isnan(temperature)) { Serial.println(\"Failed to read from DHT sensor!\"); return; } Serial.print(\"Humidity: \"); Serial.print(humidity); Serial.print(\"% Temperature: \"); Serial.print(temperature); Serial.println(\"°C\"); delay(2000); } 3\. Infrared (IR) Obstacle Avoidance Sensor Function: Detects nearby obstacles by measuring infrared reflection. Pins: VCC: Connect to 5V. GND: Connect to Ground. OUT: Output pin that goes HIGH when an object is detected (connect to a digital pin, e.g., pin 7). Code Example: const int irSensorPin = 7; int sensorState = 0; void setup() { pinMode(irSensorPin, INPUT); Serial.begin(9600); } void loop() { sensorState = digitalRead(irSensorPin); if (sensorState == HIGH) { Serial.println(\"Object detected!\"); } else { Serial.println(\"No object detected.\"); } delay(500); } 4\. Light Dependent Resistor (LDR) Function: Measures ambient light intensity. Pins: One side of LDR: Connect to 5V. Other side of LDR: Connect to an analog pin (e.g., A0) and a 10kΩ resistor leading to Ground. Code Example: const int ldrPin = A0; void setup() { Serial.begin(9600); } void loop() { int lightLevel = analogRead(ldrPin); Serial.print(\"Light Level: \"); Serial.println(lightLevel); delay(500); } 5\. Servo Motor (SG90) Function: Rotates to a specific angle (0-180 degrees), commonly used for positioning in robotic arms or microbots. Pins: VCC: Connect to 5V. GND: Connect to Ground. Signal: Control signal pin (connect to a digital PWM pin, e.g., pin 9). Code Example: Requires the Servo library (included in Arduino by default). \#include \ Servo myServo; void setup() { myServo.attach(9); // Attaches the servo to pin 9 } void loop() { myServo.write(0); // Rotate to 0 degrees delay(1000); // Wait 1 second myServo.write(90); // Rotate to 90 degrees delay(1000); myServo.write(180); // Rotate to 180 degrees delay(1000); } 6\. Infrared Distance Sensor (Sharp GP2Y0A21YK0F) Function: Measures distance by detecting reflected infrared light. Provides an analog voltage corresponding to distance. Pins: VCC: Connect to 5V. GND: Connect to Ground. OUT: Analog output pin (connect to an analog pin, e.g., A0). Code Example: This code reads the analog voltage from the sensor, which can be mapped to distance. const int irSensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(irSensorPin); float voltage = sensorValue \* (5.0 / 1023.0); // Convert to voltage // Example mapping based on sensor characteristics (adjust based on calibration) float distance = 27.86 / (voltage - 0.1); // An approximation; actual calculation may vary Serial.print(\"Distance: \"); Serial.print(distance); Serial.println(\" cm\"); delay(500); } 7\. LCD Display (16x2, I2C) Function: Displays information (e.g., sensor readings) in a 2-line, 16-character format. Pins (I2C Module): GND: Connect to Ground. VCC: Connect to 5V. SDA: Connect to A4 on an Arduino Uno (or the dedicated SDA pin if using a different Arduino model). SCL: Connect to A5 on an Arduino Uno (or the dedicated SCL pin if using a different Arduino model). Library Setup: Requires the LiquidCrystal\_I2C library. Install from the Arduino Library Manager. Code Example: \#include \ \#include \ LiquidCrystal\_I2C lcd(0x27, 16, 2); // Adjust address if needed (0x3F is another common address) void setup() { lcd.begin(16, 2); lcd.backlight(); lcd.setCursor(0, 0); lcd.print(\"Hello, World!\"); lcd.setCursor(0, 1); lcd.print(\"Arduino LCD!\"); delay(2000); } void loop() { lcd.clear(); lcd.setCursor(0, 0); lcd.print(\"Temp: 25C\"); lcd.setCursor(0, 1); lcd.print(\"Humidity: 60%\"); delay(2000); }

Use Quizgecko on...
Browser
Browser