diff --git a/3D/hardware_guide/Components/Buttons/overview.md b/3D/hardware_guide/Components/Buttons/overview.md new file mode 100644 index 0000000..c74f8f9 --- /dev/null +++ b/3D/hardware_guide/Components/Buttons/overview.md @@ -0,0 +1,62 @@ + +# Buttons and Switches + +A button or switch is a simple component that controls the flow of current in a circuit by opening or closing the connection. + +## How They Work + +- **Normally Open (NO):** This is the most common type of push button. The circuit is disconnected (open) by default. When you press the button, it completes the circuit (closes it), allowing current to flow. +- **Normally Closed (NC):** The circuit is connected (closed) by default. When you press the button, it breaks the circuit (opens it), stopping the current flow. + +## The Problem of Floating Pins + +When you connect a button to a microcontroller's input pin, you need to know its state: is it pressed or not pressed? This corresponds to a digital HIGH or LOW. + +If you just connect a button to an input pin and VCC (e.g., 5V), the pin will be HIGH when pressed. But what about when it's not pressed? The input pin is not connected to anything, which is called a **floating state**. In this state, the pin can randomly read HIGH or LOW due to electrical noise, leading to unreliable behavior. + +To fix this, we must use **pull-up** or **pull-down** resistors. + +## Pull-up and Pull-down Resistors + +These resistors ensure the input pin is always in a known, stable state. + +### 1. Pull-down Resistor + +- **How it works:** A resistor (typically 10kΩ) is connected from the input pin to Ground (GND). +- **Behavior:** + - When the button is **not pressed**, the resistor "pulls" the input pin's voltage down to GND. The pin reads **LOW**. + - When the button **is pressed**, it connects the input pin directly to VCC (5V), overriding the resistor. The pin reads **HIGH**. + +![Pull-down Resistor Diagram](https://www.upesy.com/wp-content/uploads/2021/09/pull-down-resistor-schematic.png) + +### 2. Pull-up Resistor + +- **How it works:** A resistor (typically 10kΩ) is connected from the input pin to VCC (5V). +- **Behavior:** + - When the button is **not pressed**, the resistor "pulls" the input pin's voltage up to VCC. The pin reads **HIGH**. + - When the button **is pressed**, it connects the input pin directly to GND, overriding the resistor. The pin reads **LOW**. + +![Pull-up Resistor Diagram](https://www.upesy.com/wp-content/uploads/2021/09/pull-up-resistor-schematic.png) + +**Note:** The logic is inverted with a pull-up resistor (pressed = LOW). + +## Internal Pull-ups + +Most microcontrollers (including Arduino and Raspberry Pi) have **internal pull-up resistors** that you can enable in your code. This is extremely convenient as it means you don't need to add an external resistor to your circuit. + +**Arduino Example:** +```cpp +// Enables the internal pull-up resistor on pin 2 +pinMode(2, INPUT_PULLUP); +``` + +When using `INPUT_PULLUP`, you simply wire the button between the input pin and GND. The pin will be HIGH when not pressed and LOW when pressed. + +## Debouncing + +When you press a mechanical button, the metal contacts can bounce against each other for a few milliseconds before settling. A microcontroller is fast enough to read these bounces as multiple, separate presses. + +**Debouncing** is the technique used to handle this, ensuring only one press is registered. + +- **Software Debouncing:** The most common method. After detecting a press, you can add a small delay (e.g., 50ms) in your code and then read the button state again to make sure it's still pressed. +- **Hardware Debouncing:** Can be done by adding a small capacitor to the circuit. diff --git a/3D/hardware_guide/Components/Buttons/tutorials.md b/3D/hardware_guide/Components/Buttons/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/Buttons/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/Components/LEDs/overview.md b/3D/hardware_guide/Components/LEDs/overview.md new file mode 100644 index 0000000..f825137 --- /dev/null +++ b/3D/hardware_guide/Components/LEDs/overview.md @@ -0,0 +1,62 @@ + +# LEDs (Light Emitting Diodes) + +An LED is a semiconductor light source that emits light when current flows through it. They are one of the most common components in electronics, used for everything from simple indicators to lighting. + +## How an LED Works + +- **Diode:** An LED is a type of diode, which means it only allows current to flow in one direction. +- **Polarity:** Because it's a diode, an LED has polarity. It has a positive lead (**anode**) and a negative lead (**cathode**). +- **Anode (Positive):** This is typically the longer leg. +- **Cathode (Negative):** This is typically the shorter leg. The flat edge on the side of the LED also indicates the cathode. + +If you connect an LED backwards, it will not light up and can be damaged. + +![LED Polarity Diagram](https://www.build-electronic-circuits.com/wp-content/uploads/2013/08/led-polarity.png) + +## Why You MUST Use a Resistor with an LED + +An LED has very little internal resistance. If you connect it directly to a voltage source (like a 5V pin on an Arduino), a very large amount of current will flow through it, instantly destroying the LED. This is called thermal runaway. + +To prevent this, you **must** always use a **current-limiting resistor** in series with the LED. + +### How to Calculate the Resistor Value + +You can use Ohm's Law (V = I * R) to find the right resistor value. + +**R = (Vs - Vf) / I** + +- **R:** The resistance you need (in Ohms). +- **Vs:** The voltage of your power source (e.g., 5V for an Arduino). +- **Vf:** The LED's forward voltage. This is the amount of voltage the LED "drops" when it's on. It varies by color (see chart below). +- **I:** The desired current for the LED (in Amperes). A safe and common value for most 5mm LEDs is 20mA, which is **0.020A**. + +### Typical LED Forward Voltages (Vf) + +| Color | Forward Voltage (approx.) | +| :--- | :---: | +| Red | 1.8V - 2.2V | +| Green | 2.0V - 2.4V | +| Blue | 3.0V - 3.4V | +| White | 3.0V - 3.4V | +| Yellow | 2.0V - 2.2V | + +**Example Calculation (Red LED with 5V source):** + +- Vs = 5V +- Vf = 2.0V (average for a red LED) +- I = 0.020A (20mA) + +R = (5V - 2.0V) / 0.020A + +R = 3V / 0.020A + +R = 150 Ω + +The closest standard resistor value is 220Ω, which is a perfect choice as it provides a little extra protection. + +## Types of LEDs + +- **Through-Hole:** The standard LEDs with two legs, common in breadboarding. +- **Surface Mount (SMD):** Tiny LEDs that are soldered directly onto a circuit board. +- **RGB LEDs:** These combine three separate LEDs (Red, Green, and Blue) in a single package. By controlling the brightness of each color, you can create any color in the spectrum. diff --git a/3D/hardware_guide/Components/LEDs/tutorials.md b/3D/hardware_guide/Components/LEDs/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/LEDs/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/Components/Motors/overview.md b/3D/hardware_guide/Components/Motors/overview.md new file mode 100644 index 0000000..e7a2024 --- /dev/null +++ b/3D/hardware_guide/Components/Motors/overview.md @@ -0,0 +1,40 @@ + +# Motors in Electronics + +Motors are essential components in robotics and many electronic projects. They convert electrical energy into mechanical motion. + +## Types of Motors + +There are many different types of motors, each with its own characteristics and best use cases. + +### 1. DC Motors + +- **What they are:** The most common type of motor. They have two terminals, and when you apply a DC voltage, the shaft spins. +- **Control:** The speed is controlled by varying the voltage. The direction is changed by reversing the polarity of the voltage. +- **Use Cases:** Fans, toys, robot wheels. +- **Note:** They are not precise. You can control the speed and direction, but not the exact position of the shaft. + +### 2. Servo Motors + +- **What they are:** A DC motor combined with a position feedback sensor (usually a potentiometer) and a small controller circuit. This allows for precise control of the shaft's angular position. +- **Control:** They are controlled by sending a series of pulses (Pulse Width Modulation, or PWM). The width of the pulse determines the angle of the shaft (e.g., 1ms pulse for 0 degrees, 2ms for 180 degrees). +- **Use Cases:** Robotic arms, steering systems in RC cars, pan-tilt camera mounts. + +### 3. Stepper Motors + +- **What they are:** These motors rotate in discrete steps. The shaft moves a specific number of degrees per step (e.g., 1.8 degrees per step). +- **Control:** They are controlled by energizing internal coils in a specific sequence. This requires a dedicated stepper motor driver (like an A4988 or DRV8825). +- **Use Cases:** 3D printers, CNC machines, scanners, and any application requiring precise, repeatable positioning. + +### 4. Brushless Motors + +- **What they are:** A more advanced type of motor that uses electronic commutation instead of mechanical brushes. This makes them more efficient, durable, and quieter. +- **Control:** Requires a dedicated Electronic Speed Controller (ESC) to operate. +- **Use Cases:** Drones, electric vehicles, high-performance RC cars. + +## Motor Drivers + +A microcontroller (like an Arduino or Raspberry Pi) cannot power a motor directly because motors require more current than the microcontroller's GPIO pins can supply. You **must** use a motor driver. + +- **What it does:** A motor driver is an intermediate circuit that takes a low-current control signal from the microcontroller and delivers a higher-current signal to the motor. +- **Common Examples:** L298N (for DC and stepper motors), A4988 (for stepper motors), DRV8825 (for stepper motors), ESCs (for brushless motors). diff --git a/3D/hardware_guide/Components/Motors/tutorials.md b/3D/hardware_guide/Components/Motors/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/Motors/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/Components/Potentiometers/overview.md b/3D/hardware_guide/Components/Potentiometers/overview.md new file mode 100644 index 0000000..e9bde02 --- /dev/null +++ b/3D/hardware_guide/Components/Potentiometers/overview.md @@ -0,0 +1,67 @@ + +# Potentiometers + +A potentiometer is a three-terminal variable resistor. It acts as a voltage divider and is commonly used to provide a variable analog signal to a microcontroller, for example, to control volume, brightness, or the position of a servo motor. + +## How a Potentiometer Works + +Inside a potentiometer, there is a resistive track and a sliding contact, or **wiper**. As you turn the knob, the wiper moves along the track. + +It has three pins: + +1. **Pin 1 (CCW - Counter-Clockwise):** One end of the resistive track. +2. **Pin 2 (Wiper):** The middle pin, connected to the sliding contact. +3. **Pin 3 (CW - Clockwise):** The other end of the resistive track. + +![Potentiometer Diagram](https://www.build-electronic-circuits.com/wp-content/uploads/2013/09/potentiometer-schematic-symbol-and-breadboard-layout.png) + +## Using a Potentiometer as a Voltage Divider + +This is the most common way to use a potentiometer with a microcontroller. + +1. **Connect the outer pins to power:** + - Connect Pin 1 to Ground (GND). + - Connect Pin 3 to your voltage source (e.g., 5V or 3.3V). + +2. **Connect the center pin to an analog input:** + - Connect Pin 2 (the wiper) to an analog input pin on your microcontroller (e.g., A0 on an Arduino). + +### What Happens? + +- When the knob is turned all the way to the GND side (Pin 1), the wiper is close to GND, and the voltage on the analog pin will be close to 0V. The microcontroller will read a value close to 0. +- When the knob is turned all the way to the VCC side (Pin 3), the wiper is close to VCC, and the voltage on the analog pin will be close to 5V. The microcontroller will read its maximum analog value (e.g., 1023 for a 10-bit ADC on an Arduino). +- At any position in between, the wiper picks up a voltage that is proportional to its position along the resistive track, providing a smooth range of analog values. + +## Reading the Value + +You use the `analogRead()` function on a microcontroller to read the voltage from the wiper pin. + +**Arduino Example:** + +```cpp +// Connect the potentiometer's center pin to A0 +int potPin = A0; + +void setup() { + Serial.begin(9600); +} + +void loop() { + // Read the analog value (from 0 to 1023) + int potValue = analogRead(potPin); + + // Print the value to the Serial Monitor + Serial.println(potValue); + + delay(100); // Wait a bit before the next reading +} +``` + +## Types of Potentiometers + +- **Linear Taper:** The resistance changes linearly as you turn the knob. If you turn the knob 50% of the way, the resistance is 50% of the total. These are used for most sensor control applications. +- **Logarithmic (Audio) Taper:** The resistance changes logarithmically. This is used for audio applications (like volume controls) because human hearing is also logarithmic. + +## Using a Potentiometer as a Rheostat + +A potentiometer can also be used as a simple two-terminal variable resistor (called a rheostat). You do this by using only the wiper (Pin 2) and one of the outer pins (Pin 1 or 3). In this configuration, it can be used to control the current in a circuit, for example, to vary the brightness of an LED. diff --git a/3D/hardware_guide/Components/Potentiometers/tutorials.md b/3D/hardware_guide/Components/Potentiometers/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/Potentiometers/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/Components/Resistors/overview.md b/3D/hardware_guide/Components/Resistors/overview.md new file mode 100644 index 0000000..c8c5a4f --- /dev/null +++ b/3D/hardware_guide/Components/Resistors/overview.md @@ -0,0 +1,60 @@ + +# Resistors + +A resistor is a fundamental passive electronic component that creates resistance in the flow of electric current. Its purpose is to limit current, divide voltage, and in some cases, generate heat. + +## What Does a Resistor Do? + +Imagine electricity flowing through a wire is like water flowing through a pipe. A resistor is like a narrow section of that pipe, which restricts the flow. + +Key functions: + +- **Current Limiting:** This is the most common use. For example, an LED (Light Emitting Diode) can be destroyed if too much current flows through it. A resistor is placed in series with the LED to limit the current to a safe level. +- **Voltage Division:** Two or more resistors can be used to create a voltage divider, which produces a lower, stable voltage from a higher voltage source. This is very useful for providing a specific reference voltage to a component or reading sensors. +- **Pull-up and Pull-down:** In digital logic, resistors are used to ensure that a pin is in a known state (either HIGH or LOW) when it would otherwise be "floating," such as when a button is not being pressed. + +## Units of Resistance + +The unit of electrical resistance is the **Ohm (Ω)**. + +You will commonly see values in: + +- **Ohms (Ω)** +- **Kilo-ohms (kΩ):** 1 kΩ = 1,000 Ω +- **Mega-ohms (MΩ):** 1 MΩ = 1,000,000 Ω + +## How to Read a Resistor (Color Codes) + +Through-hole resistors are too small to have their value printed on them. Instead, they use a system of colored bands. + +![Resistor Color Code Chart](https://www.build-electronic-circuits.com/wp-content/uploads/2011/11/4-band-resistor-color-code-chart.png) + +### 4-Band Resistors: + +- **Band 1:** First digit of the resistance value. +- **Band 2:** Second digit of the resistance value. +- **Band 3:** Multiplier (the number of zeros to add). +- **Band 4:** Tolerance (how accurate the resistor's value is). Gold is ±5%, Silver is ±10%. + +**Example:** + +A resistor has the colors: **Brown, Black, Red, Gold** + +1. **Brown:** 1 +2. **Black:** 0 +3. **Red:** x 100 (or add two zeros) +4. **Gold:** ±5% tolerance + +So, the value is **10** followed by **two zeros** = **1000 Ω** or **1 kΩ**, with a ±5% tolerance. + +## Ohm's Law + +The relationship between voltage (V), current (I), and resistance (R) is defined by Ohm's Law: + +**V = I * R** + +- **V:** Voltage (in Volts) +- **I:** Current (in Amperes) +- **R:** Resistance (in Ohms) + +This is the most important formula in basic electronics. You can use it to calculate the correct resistor value needed for a specific application, like protecting an LED. diff --git a/3D/hardware_guide/Components/Resistors/tutorials.md b/3D/hardware_guide/Components/Resistors/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/Resistors/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/Components/Sensors/tutorials.md b/3D/hardware_guide/Components/Sensors/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/Components/Sensors/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/.keep b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/.keep new file mode 100644 index 0000000..e69de29 diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/examples.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/examples.md new file mode 100644 index 0000000..0d6b682 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/examples.md @@ -0,0 +1,85 @@ + +# Arduino Uno Basic Examples + +Here are some basic examples to get you started with the Arduino Uno. + +## 1. Blink + +This is the "Hello, World!" of microcontrollers. It blinks the built-in LED on the Arduino board. + +```cpp +void setup() { + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop() { + digitalWrite(LED_BUILTIN, HIGH); + delay(1000); + digitalWrite(LED_BUILTIN, LOW); + delay(1000); +} +``` + +## 2. Fading an LED + +This example shows how to fade an LED on and off using one of the PWM pins. + +```cpp +int led = 9; +int brightness = 0; +int fadeAmount = 5; + +void setup() { + pinMode(led, OUTPUT); +} + +void loop() { + analogWrite(led, brightness); + brightness = brightness + fadeAmount; + if (brightness <= 0 || brightness >= 255) { + fadeAmount = -fadeAmount; + } + delay(30); +} +``` + +## 3. Reading a Sensor + +This example shows how to read the value from an analog sensor, such as a potentiometer or a photoresistor. + +```cpp +void setup() { + Serial.begin(9600); +} + +void loop() { + int sensorValue = analogRead(A0); + Serial.println(sensorValue); + delay(1); +} +``` + +## 4. Button + +This example shows how to read a pushbutton press. + +```cpp +const int buttonPin = 2; +const int ledPin = 13; + +int buttonState = 0; + +void setup() { + pinMode(ledPin, OUTPUT); + pinMode(buttonPin, INPUT); +} + +void loop() { + buttonState = digitalRead(buttonPin); + if (buttonState == HIGH) { + digitalWrite(ledPin, HIGH); + } else { + digitalWrite(ledPin, LOW); + } +} +``` diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/tutorials.md new file mode 100644 index 0000000..e7f655c --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/basicExemples.md/tutorials.md @@ -0,0 +1,97 @@ + +# Arduino Uno Tutorials + +These tutorials guide you through common beginner projects with the Arduino Uno. + +## Tutorial 1: Controlling an LED with a Potentiometer + +This project uses a potentiometer to control the brightness of an LED. + +**Hardware Needed:** +- 1 x Arduino Uno +- 1 x Breadboard +- 1 x LED +- 1 x 220Ω Resistor +- 1 x 10kΩ Potentiometer +- Jumper Wires + +**Circuit:** +1. Connect the LED to the breadboard. Connect its longer leg (anode) to the 220Ω resistor. +2. Connect the other end of the resistor to Arduino pin 9. +3. Connect the LED's shorter leg (cathode) to Arduino GND. +4. Connect the potentiometer to the breadboard. +5. Connect one outer pin of the potentiometer to 5V. +6. Connect the other outer pin to GND. +7. Connect the center pin to Arduino analog pin A0. + +![Circuit Diagram](https://www.arduino.cc/en/uploads/Tutorial/build-a-potentiometer-circuit-to-control-an-led_2.png) + +**Code:** +```cpp +const int ledPin = 9; // The pin the LED is connected to +const int potPin = A0; // The pin the potentiometer is connected to + +void setup() { + pinMode(ledPin, OUTPUT); +} + +void loop() { + // Read the potentiometer value (0-1023) + int potValue = analogRead(potPin); + + // Map the potentiometer value to the LED's PWM range (0-255) + int brightness = map(potValue, 0, 1023, 0, 255); + + // Set the LED brightness + analogWrite(ledPin, brightness); + + delay(10); +} +``` + +**How it Works:** +The Arduino reads the analog voltage from the potentiometer, which gives a value between 0 and 1023. The `map()` function scales this value to the 0-255 range required by the `analogWrite()` function to control the LED's brightness using PWM. + +--- + +## Tutorial 2: Controlling a Servo Motor + +This project shows how to sweep a servo motor back and forth. + +**Hardware Needed:** +- 1 x Arduino Uno +- 1 x Servo Motor (e.g., SG90) +- Jumper Wires + +**Circuit:** +- **Red wire (Power):** Connect to the 5V pin on the Arduino. +- **Brown/Black wire (Ground):** Connect to the GND pin on the Arduino. +- **Orange/Yellow wire (Signal):** Connect to digital pin 9 on the Arduino. + +**Code:** +```cpp +#include + +Servo myServo; // Create a servo object + +void setup() { + myServo.attach(9); // Attaches the servo on pin 9 to the servo object +} + +void loop() { + // Sweep from 0 degrees to 180 degrees + for (int pos = 0; pos <= 180; pos += 1) { + myServo.write(pos); // Tell servo to go to position in variable 'pos' + delay(15); // Waits 15ms for the servo to reach the position + } + + // Sweep from 180 degrees back to 0 degrees + for (int pos = 180; pos >= 0; pos -= 1) { + myServo.write(pos); + delay(15); + } +} +``` + +**How it Works:** +The `Servo.h` library makes it easy to control servo motors. The `myServo.write()` function sends the correct PWM signal to the servo to move it to the specified angle. diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/overview.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/overview.md new file mode 100644 index 0000000..16406d3 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/overview.md @@ -0,0 +1,35 @@ + +# Arduino Uno Overview + +The Arduino Uno is the most popular and widely used board in the Arduino family. It's a great choice for beginners and experienced users alike. + +## Key Features + +- **Microcontroller:** ATmega328P +- **Operating Voltage:** 5V +- **Input Voltage (recommended):** 7-12V +- **Digital I/O Pins:** 14 (of which 6 provide PWM output) +- **Analog Input Pins:** 6 +- **DC Current per I/O Pin:** 20 mA +- **Flash Memory:** 32 KB +- **SRAM:** 2 KB +- **EEPROM:** 1 KB +- **Clock Speed:** 16 MHz + +## Pinout + +![Arduino Uno Pinout](https://content.arduino.cc/assets/Pinout-Unorev3_latest.png) + +## Power + +The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically. + +External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or a battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector. + +## Communication + +The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. + +- **Serial:** The ATmega328P provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). +- **I2C:** The board has a dedicated I2C bus, which is available on pins A4 (SDA) and A5 (SCL). +- **SPI:** The board has a dedicated SPI bus, which is available on pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/arduinoUno/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/howToProgram.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/howToProgram.md new file mode 100644 index 0000000..535a762 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/howToProgram.md @@ -0,0 +1,44 @@ + +# How to Program an Arduino + +Programming an Arduino is done using the Arduino IDE (Integrated Development Environment), a free software that runs on your computer. + +## 1. Download and Install the Arduino IDE + +- Go to the official Arduino website: [https://www.arduino.cc/en/software](https://www.arduino.cc/en/software) +- Download the version of the IDE that is compatible with your operating system (Windows, macOS, or Linux). +- Follow the installation instructions. + +## 2. Connect the Arduino to Your Computer + +- Use a USB cable to connect your Arduino board to your computer. +- The green power LED on the board should light up. + +## 3. Configure the Arduino IDE + +- **Select your board:** Go to `Tools > Board` and select the type of Arduino board you are using (e.g., "Arduino Uno"). +- **Select the port:** Go to `Tools > Port` and select the serial port that your Arduino is connected to. This will usually be a COM port on Windows or a `/dev/tty.usbmodem` port on macOS. + +## 4. Write Your First Sketch (Program) + +An Arduino program is called a "sketch." Here is a simple example that blinks the built-in LED on the board: + +```cpp +void setup() { + // initialize digital pin LED_BUILTIN as an output. + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop() { + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(1000); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(1000); // wait for a second +} +``` + +## 5. Upload the Sketch to the Arduino + +- Click the "Upload" button (the right-arrow icon) in the Arduino IDE. +- The IDE will compile the sketch and upload it to your Arduino board. +- You should see the built-in LED on your board start to blink. diff --git a/3D/hardware_guide/MicroControllers_Computers/Arduino/intro.md b/3D/hardware_guide/MicroControllers_Computers/Arduino/intro.md new file mode 100644 index 0000000..6832538 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/Arduino/intro.md @@ -0,0 +1,21 @@ + +# Introduction to Arduino + +Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. + +## What is Arduino? + +An Arduino board is a microcontroller, which is a small computer that can be programmed to control electronic devices. It's designed to be simple and accessible, so that even beginners can get started with electronics and programming. + +## Why Use Arduino? + +- **Simplicity:** The Arduino IDE (Integrated Development Environment) is easy to use and the programming language is a simplified version of C++. +- **Cost-effective:** Arduino boards are relatively inexpensive. +- **Large Community:** There is a large online community of Arduino users who share code, tutorials, and solutions to common problems. +- **Extensible:** Arduino boards can be extended with "shields," which are add-on boards that provide additional functionality (e.g., motor control, GPS, Ethernet). + +## Common Arduino Boards + +- **Arduino Uno:** The most popular and well-documented board, great for beginners. +- **Arduino Nano:** A smaller version of the Uno, ideal for projects with limited space. +- **Arduino Mega:** A larger board with more pins and memory, suitable for more complex projects. diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/conections.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/conections.md new file mode 100644 index 0000000..7feaaeb --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/conections.md @@ -0,0 +1,49 @@ + +# ESP32-CAM Connections + +Connecting the ESP32-CAM to other components and programming it requires a few specific connections. + +## Programming Connections (using an FTDI Programmer) + +To upload code to the ESP32-CAM, you need an FTDI (Future Technology Devices International) programmer, which is a USB-to-serial converter. + +Here are the necessary connections: + +| ESP32-CAM Pin | FTDI Programmer Pin | +| :---: | :---: | +| 5V | VCC (5V) | +| GND | GND | +| U0TXD | RXD | +| U0RXD | TXD | + +**Crucial Step for Uploading:** Before you can upload a sketch, you must connect the `GPIO 0` pin to `GND`. This action puts the ESP32-CAM into flashing mode. + +### Uploading Procedure: + +1. Make the connections listed in the table above. +2. Connect `GPIO 0` to `GND`. +3. Connect the FTDI programmer to your computer via USB. +4. Open your programming environment (e.g., Arduino IDE). +5. Select the correct board (`AI Thinker ESP32-CAM`) and COM port. +6. Press the "Upload" button. +7. Once the upload is complete, **disconnect `GPIO 0` from `GND`**. +8. Press the onboard reset (RST) button to start running your new program. + +## Powering the ESP32-CAM + +While you can power the board through the FTDI programmer during development, for standalone projects, it's highly recommended to use a dedicated 5V power supply. + +- **Using the 5V Pin:** Connect a stable 5V power source to the `5V` and `GND` pins. The power supply should be able to provide at least 2A, especially when the camera and Wi-Fi are active, to prevent brownouts and instability. + +## MicroSD Card Connections + +The ESP32-CAM has a built-in MicroSD card slot. The connections are internal, so you just need to insert a formatted MicroSD card (up to 4GB is officially supported, but larger cards may work). + +The following GPIO pins are used by the MicroSD card reader: + +- **GPIO 14:** CLK +- **GPIO 15:** CMD +- **GPIO 2:** Data0 +- **GPIO 4:** Data1 (also used for the onboard flash LED) +- **GPIO 12:** Data2 +- **GPIO 13:** Data3 diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/overview.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/overview.md new file mode 100644 index 0000000..1e3c273 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/overview.md @@ -0,0 +1,30 @@ + +# ESP32-CAM Overview + +The ESP32-CAM is a small, low-cost development board that combines an ESP32-S microcontroller with a 2-megapixel OV2640 camera. It's an excellent choice for projects that require video streaming, image capture, or computer vision. + +## Key Features + +- **Microcontroller:** ESP32-S +- **Camera:** OV2640 (2MP) +- **Flash Memory:** 4MB +- **RAM:** 520KB SRAM + 4MB PSRAM +- **Wi-Fi:** 802.11 b/g/n +- **Bluetooth:** v4.2 BR/EDR and BLE +- **GPIO:** 9 available GPIO pins +- **Storage:** MicroSD card slot (up to 4GB) +- **Power:** 5V input + +## Pinout + +![ESP32-CAM Pinout](https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2019/03/esp32-cam-pinout-ai-thinker.png?w=712&quality=100&strip=all&ssl=1) + +## Getting Started + +To use the ESP32-CAM, you'll need an FTDI programmer to upload code. The board does not have a built-in USB-to-serial converter. + +**Important:** Before uploading code, you must connect the `GPIO 0` pin to `GND`. This puts the board into flashing mode. After the code is uploaded, disconnect `GPIO 0` from `GND` and press the reset button to run the new sketch. + +## Powering the ESP32-CAM + +The board can be powered through the 5V pin. It's recommended to use an external 5V power supply that can provide at least 2A, especially when using the camera, as it can be power-hungry. diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials.md new file mode 100644 index 0000000..d5f157f --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials.md @@ -0,0 +1,3 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs + +https://www.youtube.com/watch?v=hSr557hppwY \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials/tutorials.md new file mode 100644 index 0000000..75d1dc2 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32CAM/tutorials/tutorials.md @@ -0,0 +1,127 @@ + + +# ESP32-CAM Tutorials + +Here are some tutorials to help you get started with the ESP32-CAM. + +## 1. Camera Web Server + +This is the most popular ESP32-CAM project. It hosts a web page on your local network that streams video from the camera. + +### Arduino IDE Setup + +1. **Board:** In the Arduino IDE, go to `Tools > Board` and select "AI Thinker ESP32-CAM". +2. **Example Sketch:** Go to `File > Examples > ESP32 > Camera` and open the `CameraWebServer` example. + +### Code Configuration + +In the `CameraWebServer` sketch, you need to make a few changes: + +1. **Select Camera Model:** Uncomment the line for the AI-Thinker model: + ```cpp + #define CAMERA_MODEL_AI_THINKER + ``` +2. **Enter Wi-Fi Credentials:** Find the following lines and replace `ssid` and `password` with your Wi-Fi network's name and password: + ```cpp + const char* ssid = "YOUR_SSID"; + const char* password = "YOUR_PASSWORD"; + ``` + +### Upload and Run + +1. Follow the programming connections and procedure outlined in the `conections.md` file (connect `GPIO 0` to `GND`). +2. Upload the sketch. +3. Disconnect `GPIO 0` from `GND` and press the reset button. +4. Open the Serial Monitor and set the baud rate to `115200`. +5. The ESP32-CAM will connect to your Wi-Fi and print its IP address in the Serial Monitor. +6. Open a web browser on a device connected to the same Wi-Fi network and enter the IP address. +7. You should see a web page with a video stream from your camera! + +## 2. Taking a Photo and Saving to MicroSD Card + +This project shows you how to capture an image and save it as a `.jpg` file on a MicroSD card. + +### Arduino IDE Setup + +1. Make sure you have the ESP32 board support installed. +2. Insert a formatted MicroSD card into the ESP32-CAM's card slot. + +### Example Code + +This code initializes the camera and the SD card, takes a picture, and saves it. You can then trigger this action with a button press or another sensor. + +```cpp +#include "esp_camera.h" +#include "FS.h" +#include "SD_MMC.h" + +// Pin definition for CAMERA_MODEL_AI_THINKER +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +void setup() { + Serial.begin(115200); + Serial.setDebugOutput(true); + Serial.println(); + + camera_config_t config; + // ... (camera configuration - see full example online) ... + + // initialize the camera + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + Serial.printf("Camera init failed with error 0x%x", err); + return; + } + + if(!SD_MMC.begin()){ + Serial.println("Card Mount Failed"); + return; + } + uint8_t cardType = SD_MMC.cardType(); + if(cardType == CARD_NONE){ + Serial.println("No SD card attached"); + return; + } + + // Take a picture + camera_fb_t * fb = esp_camera_fb_get(); + if(!fb) { + Serial.println("Camera capture failed"); + return; + } + + // Save picture to microSD card + fs::FS &fs = SD_MMC; + String path = "/picture.jpg"; + File file = fs.open(path.c_str(), FILE_WRITE); + if(!file){ + Serial.println("Failed to open file in writing mode"); + } else { + file.write(fb->buf, fb->len); // payload (image), payload length + Serial.printf("Saved file to path: %s\n", path.c_str()); + } + file.close(); + esp_camera_fb_return(fb); +} + +void loop() { + // Code in setup runs once +} +``` +*Note: This is a simplified version. For the full, working code, please refer to online tutorials from resources like Random Nerd Tutorials.* + diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32S3/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32S3/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/ESP32S3/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/.keep b/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/.keep new file mode 100644 index 0000000..e69de29 diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/examples.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/examples.md new file mode 100644 index 0000000..cef7129 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/examples.md @@ -0,0 +1,82 @@ + +# ESP32 Basic Examples + +Here are some basic examples to get you started with the ESP32. + +## 1. Wi-Fi Scan + +This example shows how to scan for available Wi-Fi networks. + +```cpp +#include "WiFi.h" + +void setup() { + Serial.begin(115200); + + // Set WiFi to station mode and disconnect from an AP if it was previously connected + WiFi.mode(WIFI_STA); + WiFi.disconnect(); + delay(100); + + Serial.println("Setup done"); +} + +void loop() { + Serial.println("Scan start"); + + // WiFi.scanNetworks will return the number of networks found + int n = WiFi.scanNetworks(); + Serial.println("Scan done"); + if (n == 0) { + Serial.println("no networks found"); + } else { + Serial.print(n); + Serial.println(" networks found"); + for (int i = 0; i < n; ++i) { + // Print SSID and RSSI for each network found + Serial.print(i + 1); + Serial.print(": "); + Serial.print(WiFi.SSID(i)); + Serial.print(" ("); + Serial.print(WiFi.RSSI(i)); + Serial.print(")"); + Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*"); + delay(10); + } + } + Serial.println(""); + + // Wait a bit before scanning again + delay(5000); +} +``` + +## 2. Bluetooth Serial + +This example shows how to use Bluetooth to send and receive data. + +```cpp +#include "BluetoothSerial.h" + +#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) +#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it +#endif + +BluetoothSerial SerialBT; + +void setup() { + Serial.begin(115200); + SerialBT.begin("ESP32test"); //Bluetooth device name + Serial.println("The device started, now you can pair it with bluetooth!"); +} + +void loop() { + if (Serial.available()) { + SerialBT.write(Serial.read()); + } + if (SerialBT.available()) { + Serial.write(SerialBT.read()); + } + delay(20); +} +``` diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/tutorials.md new file mode 100644 index 0000000..2c86312 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/basicExemples.md/tutorials.md @@ -0,0 +1,159 @@ + +# ESP32 Tutorials + +These tutorials leverage the unique features of the ESP32, like Wi-Fi and Bluetooth. + +## Tutorial 1: Web Server to Control an LED + +This project creates a simple web server on your network. You can visit the server's IP address in a browser to turn an LED connected to the ESP32 on or off. + +**Hardware Needed:** +- 1 x ESP32 Development Board +- 1 x Breadboard +- 1 x LED +- 1 x 330Ω Resistor +- Jumper Wires + +**Circuit:** +1. Connect the LED's longer leg (anode) to a 330Ω resistor. +2. Connect the other end of the resistor to GPIO 2 on the ESP32. +3. Connect the LED's shorter leg (cathode) to a GND pin on the ESP32. + +**Code:** +*Remember to add your Wi-Fi credentials to the code.* +```cpp +#include + +// Replace with your network credentials +const char* ssid = "YOUR_SSID"; +const char* password = "YOUR_PASSWORD"; + +// Set web server port number to 80 +WiFiServer server(80); + +// Variable to store the HTTP request +String header; + +// GPIO where the LED is connected +const int ledPin = 2; + +void setup() { + Serial.begin(115200); + pinMode(ledPin, OUTPUT); + digitalWrite(ledPin, LOW); + + // Connect to Wi-Fi + Serial.print("Connecting to "); + Serial.println(ssid); + WiFi.begin(ssid, password); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + // Print local IP address and start web server + Serial.println("\nWiFi connected."); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + server.begin(); +} + +void loop(){ + WiFiClient client = server.available(); + + if (client) { + String currentLine = ""; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + header += c; + if (c == '\n') { + if (currentLine.length() == 0) { + // HTTP headers + client.println("HTTP/1.1 200 OK"); + client.println("Content-type:text/html"); + client.println("Connection: close"); + client.println(); + + // Web page content + if (header.indexOf("GET /2/on") >= 0) { + digitalWrite(ledPin, HIGH); + } else if (header.indexOf("GET /2/off") >= 0) { + digitalWrite(ledPin, LOW); + } + client.println(""); + client.println(""); + client.println(""); + client.println("

ESP32 Web Server

"); + client.println("

"); + client.println("

"); + client.println(""); + client.println(); + break; + } + } + else { + currentLine += c; + } + } + } + header = ""; + client.stop(); + } +} +``` + +**How it Works:** +The ESP32 connects to your Wi-Fi and starts a web server. When you visit its IP address, it serves a simple HTML page with "ON" and "OFF" buttons. Clicking these buttons sends a request back to the ESP32 (e.g., `http://[IP]/2/on`), which the code checks for to turn the LED on or off. + +--- + +## Tutorial 2: Bluetooth Low Energy (BLE) Scanner + +This project uses the ESP32's BLE capabilities to scan for nearby Bluetooth devices and print their information to the Serial Monitor. + +**Hardware Needed:** +- 1 x ESP32 Development Board + +**Code:** +```cpp +#include +#include +#include +#include + +int scanTime = 5; //In seconds +BLEScan* pBLEScan; + +class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { + void onResult(BLEAdvertisedDevice advertisedDevice) { + Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str()); + } +}; + +void setup() { + Serial.begin(115200); + Serial.println("Scanning..."); + + BLEDevice::init(""); + pBLEScan = BLEDevice::getScan(); //create new scan + pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); + pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster + pBLEScan->setInterval(100); + pBLEScan->setWindow(99); +} + +void loop() { + // put your main code here, to run repeatedly: + BLEScanResults foundDevices = pBLEScan->start(scanTime, false); + Serial.print("Devices found: "); + Serial.println(foundDevices.getCount()); + Serial.println("Scan done!"); + pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory + delay(2000); +} +``` + +**How it Works:** +The ESP32 initializes its BLE radio and performs a scan for a set duration (`scanTime`). When it discovers a device that is advertising its presence, the `onResult` callback function is triggered, printing the device's address and other available information to the serial port. diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/howToProgram.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/howToProgram.md new file mode 100644 index 0000000..14ff658 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/howToProgram.md @@ -0,0 +1,56 @@ + +# How to Program an ESP32 + +Programming the ESP32 is similar to programming an Arduino. You can use the Arduino IDE with an extension, or you can use other development environments like PlatformIO or the official Espressif IDF (IoT Development Framework). + +## Using the Arduino IDE + +This is the most common method for beginners. + +### 1. Install the Arduino IDE + +If you haven't already, download and install the Arduino IDE from the [official website](https://www.arduino.cc/en/software). + +### 2. Add ESP32 Board Support to Arduino IDE + +- Open the Arduino IDE. +- Go to `File > Preferences`. +- In the "Additional Board Manager URLs" field, enter the following URL: + ``` + https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + ``` +- Click "OK". +- Go to `Tools > Board > Boards Manager...`. +- Search for "esp32" and install the "esp32 by Espressif Systems" package. + +### 3. Configure the IDE for Your ESP32 Board + +- Connect your ESP32 board to your computer with a USB cable. +- Go to `Tools > Board` and select your specific ESP32 board (e.g., "ESP32 Dev Module"). +- Go to `Tools > Port` and select the correct serial port. + +### 4. Write and Upload a Sketch + +Now you can write code just like you would for an Arduino. Here's a "Hello, World!" example for the ESP32, which prints to the Serial Monitor. + +```cpp +void setup() { + Serial.begin(115200); +} + +void loop() { + Serial.println("Hello from ESP32!"); + delay(1000); +} +``` + +- Click the "Upload" button to flash the code onto your ESP32. +- Open the Serial Monitor (`Tools > Serial Monitor`) and set the baud rate to 115200 to see the output. + +## Using PlatformIO + +PlatformIO is a more advanced, cross-platform build system that integrates with code editors like VS Code. It offers better library management and is preferred for larger projects. + +- **Installation:** Install Visual Studio Code and then install the PlatformIO IDE extension from the marketplace. +- **Project Setup:** Create a new PlatformIO project and select your ESP32 board. +- **Programming:** Write your code in the `src/main.cpp` file and use the PlatformIO interface to build and upload. diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/intro.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/intro.md new file mode 100644 index 0000000..50e695b --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/intro.md @@ -0,0 +1,22 @@ + +# Introduction to ESP32 + +The ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. It is the successor to the ESP8266 and is developed by Espressif Systems. + +## What is an ESP32? + +The ESP32 is a powerful microcontroller that is well-suited for a wide range of applications, including IoT (Internet of Things), home automation, and robotics. It has a number of features that make it a popular choice for hobbyists and professionals alike. + +## Why Use ESP32? + +- **Wi-Fi and Bluetooth:** The ESP32 has built-in Wi-Fi and Bluetooth, which makes it easy to connect to the internet and other devices. +- **Dual-Core Processor:** The ESP32 has a dual-core processor, which allows it to perform multiple tasks at the same time. +- **Low Power Consumption:** The ESP32 is designed to be low-power, which makes it ideal for battery-powered applications. +- **Cost-effective:** ESP32 boards are very affordable. +- **Large Community:** There is a large and active community of ESP32 users who provide support and share projects. + +## Common ESP32 Boards + +- **ESP32-WROOM-32:** A popular and versatile module that can be found on many development boards. +- **ESP32-CAM:** A small board with a built-in camera, ideal for video streaming and image processing projects. +- **ESP32-S3:** A newer version of the ESP32 with more features, including a more powerful processor and more memory. diff --git a/3D/hardware_guide/MicroControllers_Computers/ESP32/tutorials/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/ESP32/tutorials/tutorials.md new file mode 100644 index 0000000..0abffd7 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/ESP32/tutorials/tutorials.md @@ -0,0 +1,3 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs + +https://github.com/yoursunny/esp32cam \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/basicExemples.md/examples.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/basicExemples.md/examples.md new file mode 100644 index 0000000..6b589b9 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/basicExemples.md/examples.md @@ -0,0 +1,110 @@ + +# Raspberry Pi Basic Examples (Python) + +These examples use the `gpiozero` library, which is a friendly and intuitive way to interact with the GPIO pins on a Raspberry Pi. + +## 1. Blinking an LED + +This is the fundamental "Hello, World!" of physical computing. + +**Hardware:** +- 1 x LED +- 1 x 330Ω Resistor +- Connect the longer leg (anode) of the LED to GPIO pin 17. +- Connect the shorter leg (cathode) to the resistor, and the other end of the resistor to a Ground (GND) pin. + +**Code (`blink.py`):** +```python +from gpiozero import LED +from time import sleep + +# Initialize the LED on GPIO pin 17 +led = LED(17) + +print("LED will blink. Press Ctrl+C to exit.") + +try: + while True: + led.on() # Turn the LED on + sleep(1) # Wait for 1 second + led.off() # Turn the LED off + sleep(1) # Wait for 1 second +except KeyboardInterrupt: + print("\nExiting program.") + led.off() # Ensure LED is off when program exits +``` + +**To Run:** +```bash +python blink.py +``` + +## 2. Reading a Button Press + +This example shows how to get digital input from a push button. + +**Hardware:** +- 1 x Push Button +- Connect one leg of the button to GPIO pin 2. +- Connect the other leg to a Ground (GND) pin. + +**Code (`button_test.py`):** +```python +from gpiozero import Button +from time import sleep + +# Initialize the Button on GPIO pin 2 +# The internal pull-up resistor is enabled by default +button = Button(2) + +print("Press the button. Press Ctrl+C to exit.") + +try: + while True: + if button.is_pressed: + print("Button is pressed") + else: + print("Button is not pressed") + sleep(0.1) +except KeyboardInterrupt: + print("\nExiting program.") +``` + +**To Run:** +```bash +python button_test.py +``` + +## 3. Button-Controlled LED + +This combines the previous two examples. + +**Hardware:** +- Same as the LED and Button examples above. + +**Code (`button_led.py`):** +```python +from gpiozero import LED, Button +from signal import pause + +led = LED(17) +button = Button(2) + +print("Press the button to turn the LED on/off. Press Ctrl+C to exit.") + +# The following lines link the button's state to the LED's state +# button.when_pressed = led.on +# button.when_released = led.off + +# A more direct way to do the same thing: +led.source = button.values + +# pause() keeps the script running until you exit with Ctrl+C +pause() +``` + +**To Run:** +```bash +python button_led.py +``` + diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/overview.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/overview.md new file mode 100644 index 0000000..92dd710 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/overview.md @@ -0,0 +1,33 @@ + +# Raspberry Pi 4 Model B Overview + +The Raspberry Pi 4 Model B is a significant upgrade from its predecessors, offering desktop performance in a tiny, affordable package. It's the most powerful and versatile board in the Raspberry Pi lineup, making it ideal for a huge range of projects, from home servers to complex robotics. + +## Key Features + +- **Processor:** Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz (can be overclocked). +- **RAM:** Available in 1GB, 2GB, 4GB, or 8GB LPDDR4-3200 SDRAM options. +- **Connectivity:** + - 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless LAN, Bluetooth 5.0, BLE. + - Gigabit Ethernet. + - 2 × USB 3.0 ports; 2 × USB 2.0 ports. +- **Video & Sound:** + - 2 × micro-HDMI ports (supports up to 4kp60). + - 4-pole stereo audio and composite video port. +- **GPIO:** Standard 40-pin GPIO header (fully backwards compatible with previous boards). +- **Storage:** MicroSD card slot for loading operating system and data storage. +- **Power:** 5V DC via USB-C connector (minimum 3A recommended). + +## Pinout + +The Raspberry Pi 4 maintains the same standard 40-pin GPIO header as previous models, ensuring compatibility with most existing HATs and add-on boards. + +![Raspberry Pi 4 Pinout](https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png) + +## Key Differences from Previous Models + +- **CPU Performance:** A major leap in processing power. +- **RAM Options:** The first Pi to offer up to 8GB of RAM, making it a true desktop replacement. +- **Dual Monitor Support:** Two micro-HDMI ports allow for a dual-screen setup. +- **USB 3.0:** Faster data transfer with two USB 3.0 ports. +- **Power Connector:** Moved to USB-C to support the higher power requirements. diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/tutorials.md new file mode 100644 index 0000000..8c66150 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/Raspberry Pi 4 Model B/tutorials.md @@ -0,0 +1 @@ +https://www.youtube.com/watch?v=RiYnucfy_rs \ No newline at end of file diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/howToProgram.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/howToProgram.md new file mode 100644 index 0000000..9220c7b --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/howToProgram.md @@ -0,0 +1,66 @@ + +# How to Program a Raspberry Pi + +Programming a Raspberry Pi is different from programming a microcontroller. Since the Raspberry Pi is a full computer running an operating system (like Raspberry Pi OS), you write and run code directly on the device itself. + +## 1. Setting Up Your Raspberry Pi + +First, you need to get your Raspberry Pi running. + +- **Install Raspberry Pi OS:** Download the Raspberry Pi Imager from the [official website](https://www.raspberrypi.com/software/) and use it to flash the Raspberry Pi OS onto a microSD card. +- **Initial Boot:** Insert the microSD card into your Pi, connect a monitor, keyboard, mouse, and power supply, and turn it on. +- **Complete Setup:** Follow the on-screen instructions to set up your location, password, and connect to Wi-Fi. + +## 2. Accessing Your Raspberry Pi + +You have two main ways to work with your Raspberry Pi: + +- **Desktop Environment:** Use it like a regular computer with the connected monitor, keyboard, and mouse. +- **Headless (Remote Access):** Access your Pi from another computer over the network using SSH (for a command-line interface) or VNC (for the full graphical desktop). This is very common for robotics and embedded projects. + +To enable SSH and VNC, open the Raspberry Pi Configuration tool (`Menu > Preferences > Raspberry Pi Configuration > Interfaces`) and enable them. + +## 3. Programming Languages + +Python is the most popular and officially recommended language for programming on the Raspberry Pi. Raspberry Pi OS comes with Python and several useful libraries pre-installed. + +### Writing and Running a Python Script + +1. **Open a Code Editor:** You can use the pre-installed **Thonny IDE**, which is excellent for beginners, or any other text editor like VS Code (which can be installed on the Pi). +2. **Write Your Code:** Create a new file and write your Python code. For example, a simple "Hello, World!" script named `hello.py`: + ```python + print("Hello from the Raspberry Pi!") + ``` +3. **Save the File:** Save the script in your home directory or a project folder. +4. **Run from the Terminal:** + - Open the **Terminal** application. + - Navigate to the directory where you saved your file using the `cd` command (e.g., `cd my_project`). + - Run the script using the python interpreter: + ```bash + python hello.py + ``` + +## 4. Controlling GPIO Pins + +The real power for physical computing comes from the GPIO (General-Purpose Input/Output) pins. You can use Python libraries to control them. + +- **gpiozero:** A modern, beginner-friendly library for controlling GPIO devices. +- **RPi.GPIO:** The classic, more traditional library for GPIO control. + +### Example: Blinking an LED with `gpiozero` + +1. **Connect the Hardware:** Connect an LED to GPIO pin 17 and a ground pin on the Raspberry Pi (don't forget a resistor!). +2. **Write the Python Script:** + ```python + from gpiozero import LED + from time import sleep + + led = LED(17) + + while True: + led.on() + sleep(1) + led.off() + sleep(1) + ``` +3. **Run the Script:** Save the code and run it from the terminal (`python blink.py`). The LED should start blinking. diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/intro.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/intro.md new file mode 100644 index 0000000..9c6c384 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/intro.md @@ -0,0 +1,27 @@ + +# Introduction to Raspberry Pi + +The Raspberry Pi is a low-cost, credit-card-sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. + +## What is a Raspberry Pi? + +Unlike a microcontroller like an Arduino or ESP32, a Raspberry Pi is a full-fledged single-board computer (SBC). This means it runs a complete operating system (typically a version of Linux called Raspberry Pi OS) and can do most things a desktop computer can do, like browsing the internet, playing videos, and running software. + +## Why Use a Raspberry Pi? + +- **Versatility:** It can be used as a desktop computer, a web server, a home automation hub, a retro gaming console, a robot brain, and much more. +- **Linux Operating System:** Running a full OS gives you immense power and flexibility. You can install a vast range of open-source software and tools. +- **Processing Power:** Modern Raspberry Pi models have multi-core processors and significant RAM, making them suitable for more computationally intensive tasks than microcontrollers. +- **Connectivity:** They come with USB ports, Ethernet, Wi-Fi, Bluetooth, and HDMI, making it easy to connect peripherals. +- **GPIO Pins:** Like microcontrollers, the Raspberry Pi has a row of General-Purpose Input/Output (GPIO) pins that allow it to control electronic components like LEDs, motors, and sensors. + +## Common Raspberry Pi Models + +- **Raspberry Pi 4 Model B:** A powerful and popular model with different RAM options (2GB, 4GB, 8GB), dual-monitor support, and USB 3.0 ports. +- **Raspberry Pi Zero 2 W:** A tiny, low-cost Pi with wireless connectivity, ideal for small, embedded projects. +- **Raspberry Pi Pico:** This is an exception! The Pico is a **microcontroller**, not a single-board computer. It's designed by the Raspberry Pi Foundation to compete with Arduino and is programmed in C/C++ or MicroPython. + +## Raspberry Pi vs. Arduino/ESP32 + +- **Choose a Raspberry Pi when:** You need a full operating system, networking, significant processing power, or want to run complex applications (e.g., a web server, machine learning inference, a media center). +- **Choose an Arduino/ESP32 when:** You need to perform simple, repetitive tasks with low power consumption, read sensors, and control motors in a very reliable and real-time manner. diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPi4/basicExemples.md/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPi4/basicExemples.md/tutorials.md new file mode 100644 index 0000000..51ca47e --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPi4/basicExemples.md/tutorials.md @@ -0,0 +1,129 @@ +# Raspberry Pi 4 Tutorials + +These tutorials use Python and the `gpiozero` library to interact with hardware. + +## Tutorial 1: Reading a Temperature and Humidity Sensor (DHT11/DHT22) + +This project reads environmental data from a popular DHT sensor and prints it to the console. + +**Hardware Needed:** +- 1 x Raspberry Pi 4 +- 1 x DHT11 (blue) or DHT22 (white) sensor +- Jumper Wires + +**Circuit:** +- **DHT Pin 1 (VCC):** Connect to 3.3V on the Raspberry Pi. +- **DHT Pin 2 (Data):** Connect to GPIO 4 on the Raspberry Pi. +- **DHT Pin 4 (GND):** Connect to a GND pin on the Raspberry Pi. +(Pin 3 is not used). + +**Software Setup:** +You need to install the Adafruit CircuitPython DHT library. + +```bash +sudo apt-get update +sudo apt-get install python3-pip +sudo pip3 install adafruit-circuitpython-dht +sudo apt-get install libgpiod2 +``` + +**Code (`temp_reader.py`):** +```python +import time +import board +import adafruit_dht + +# Initialize the dht device, with data pin connected to: +dhtDevice = adafruit_dht.DHT22(board.D4) # Use DHT22 for DHT22, or DHT11 for DHT11 + +while True: + try: + # Print the values to the serial port + temperature_c = dhtDevice.temperature + temperature_f = temperature_c * (9 / 5) + 32 + humidity = dhtDevice.humidity + print( + "Temp: {:.1f} F / {:.1f} C Humidity: {}%".format( + temperature_f, temperature_c, humidity + ) + ) + + except RuntimeError as error: + # Errors happen fairly often, DHT's are tricky that way! + print(error.args[0]) + time.sleep(2.0) + continue + except Exception as error: + dhtDevice.exit() + raise error + + time.sleep(2.0) + +``` + +**How it Works:** +The `adafruit_circuitpython_dht` library handles the complex timing required to read data from the DHT sensor. The script initializes the sensor on the specified GPIO pin and then enters a loop, reading the temperature and humidity every 2 seconds. + +--- + +## Tutorial 2: Controlling a DC Motor with an L298N Driver + +This project shows how to control the speed and direction of a simple DC motor. + +**Hardware Needed:** +- 1 x Raspberry Pi 4 +- 1 x L298N Motor Driver +- 1 x DC Motor +- An external power supply for the motor (e.g., a 9V battery or a 5V-12V power adapter). **Do not power the motor from the Pi!** +- Jumper Wires + +**Circuit:** +1. Connect the L298N's `VCC` and `GND` to your external power supply. +2. Connect the motor to the `OUT1` and `OUT2` terminals on the L298N. +3. Connect the L298N's `IN1` to Raspberry Pi GPIO 24. +4. Connect the L298N's `IN2` to Raspberry Pi GPIO 23. +5. Connect the L298N's `ENA` (Enable A) to Raspberry Pi GPIO 25. +6. **Crucially, connect one of the Raspberry Pi's GND pins to the L298N's GND pin.** This creates a common ground, which is essential for the circuit to work. + +**Code (`motor_control.py`):** +```python +from gpiozero import Motor, PWMOutputDevice +from time import sleep + +# The Motor class uses two pins for direction +motor = Motor(forward=24, backward=23) + +# The PWMOutputDevice is used for speed control +speed_control = PWMOutputDevice(25) + +print("Motor test starting...") + +try: + while True: + print("Full speed forward") + motor.forward() + speed_control.value = 1.0 # Full speed (0.0 to 1.0) + sleep(2) + + print("Half speed forward") + speed_control.value = 0.5 + sleep(2) + + print("Full speed backward") + motor.backward() + speed_control.value = 1.0 + sleep(2) + + print("Stopping") + motor.stop() + sleep(2) + +except KeyboardInterrupt: + print("\nExiting program.") + motor.stop() + +``` + +**How it Works:** +The `gpiozero` `Motor` class simplifies motor control. It uses one pin for forward and another for backward. The `PWMOutputDevice` is used on the L298N's "Enable" pin to control the motor's speed. A `value` of 1.0 is full speed, and 0.0 is stopped. + diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/overview.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/overview.md new file mode 100644 index 0000000..121f28e --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/overview.md @@ -0,0 +1,41 @@ + +# Raspberry Pi Zero 2 W Overview + +The Raspberry Pi Zero 2 W is a tiny, low-cost, and yet surprisingly powerful member of the Raspberry Pi family. It packs the processing power of the Raspberry Pi 3 into the miniature form factor of the original Pi Zero, making it an ideal choice for compact and low-power projects that require wireless connectivity. + +## Key Features + +- **Processor:** Broadcom BCM2710A1, Quad-core 64-bit SoC (ARM Cortex-A53 @ 1GHz). This is the same family as the Raspberry Pi 3. +- **RAM:** 512MB LPDDR2 SDRAM. +- **Connectivity:** + - 2.4GHz IEEE 802.11b/g/n wireless LAN. + - Bluetooth 4.2, Bluetooth Low Energy (BLE). +- **Form Factor:** Incredibly small, measuring just 65mm x 30mm. +- **Video & Sound:** + - Mini HDMI port. + - Composite video and reset pins via solder test points. +- **Camera Interface:** CSI-2 camera connector. +- **GPIO:** 40-pin GPIO header (unpopulated, requires soldering). +- **Storage:** MicroSD card slot. +- **Power:** 5V DC via micro USB connector. + +## Pinout + +The Raspberry Pi Zero 2 W uses the standard 40-pin GPIO layout, but the header is unpopulated to save space. You will need to solder on a pin header to use the GPIO pins with breadboards or HATs. + +![Raspberry Pi Zero 2 W Pinout](https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png) + +## Key Differences + +- **vs. Pi Zero W:** The Zero 2 W is a major performance upgrade, with a quad-core processor that is roughly 5 times faster for multi-threaded tasks. This makes it much more capable for running applications beyond simple scripts. +- **vs. Pi 4:** The Pi 4 is significantly more powerful, has much more RAM, USB 3.0, Gigabit Ethernet, and dual 4K monitor support. The Zero 2 W is designed for projects where size, cost, and power consumption are the primary concerns, while the Pi 4 is a true desktop replacement. + +## Common Use Cases + +The small size and wireless capabilities of the Zero 2 W make it perfect for: + +- **IoT Devices:** Smart home sensors, weather stations. +- **Portable Projects:** Handheld retro gaming consoles (like Pi-hole). +- **Robotics:** The brain for a small robot where space is tight. +- **Security Cameras:** A tiny, discreet network security camera. +- **Wearables:** Projects that need to be embedded in clothing or accessories. diff --git a/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/tutorials.md b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/tutorials.md new file mode 100644 index 0000000..8a75879 --- /dev/null +++ b/3D/hardware_guide/MicroControllers_Computers/RaspberryPi/raspberryPiZero2W/tutorials.md @@ -0,0 +1,112 @@ + + +# Raspberry Pi Zero 2 W Tutorials + +Programming the Pi Zero 2 W is identical to any other Raspberry Pi. These tutorials focus on projects that are well-suited to its small size and lower power consumption. + +## Tutorial 1: Creating a Wireless Network Scanner + +This project turns your Pi Zero 2 W into a portable device that can scan for Wi-Fi networks and display their details. This is great for a "headless" (no monitor) setup. + +**Hardware Needed:** +- 1 x Raspberry Pi Zero 2 W +- A power source (e.g., a USB power bank) + +**Software Setup:** +This project uses standard Python libraries that come with Raspberry Pi OS. + +**Code (`wifi_scanner.py`):** +```python +import subprocess +import time + +def scan_wifi(): + """Scans for Wi-Fi networks and returns a list of SSIDs.""" + try: + # Use the nmcli tool to scan for networks + scan_result = subprocess.check_output(['nmcli', 'dev', 'wifi'], text=True) + networks = [] + for line in scan_result.split('\n'): + if line.strip().startswith('*'): + # This is the currently connected network + continue + if len(line.strip()) > 0 and not line.startswith('IN-USE'): + parts = line.strip().split() + if len(parts) > 1: + ssid = parts[1] + if ssid != '--': + networks.append(ssid) + return list(set(networks)) # Return unique SSIDs + except (subprocess.CalledProcessError, FileNotFoundError): + print("Could not execute nmcli. Make sure it's installed.") + return [] + +if __name__ == "__main__": + print("Starting Wi-Fi scan... Press Ctrl+C to stop.") + try: + while True: + print("\n--- New Scan ---") + found_networks = scan_wifi() + if found_networks: + for network in found_networks: + print(f"Found network: {network}") + else: + print("No networks found.") + time.sleep(10) # Wait 10 seconds before scanning again + except KeyboardInterrupt: + print("\nScan stopped.") + +``` + +**How to Run (Headless):** +1. Save this script on your Pi Zero 2 W. +2. SSH into your Pi from another computer. +3. Run the script: `python wifi_scanner.py` +4. The Pi will continuously scan for and display the names (SSIDs) of nearby Wi-Fi networks. + +--- + +## Tutorial 2: Headless Button-Controlled LED + +This project shows how to control an LED with a button without needing a monitor. It's a perfect example of a simple, embedded application for the Zero 2 W. + +**Hardware Needed:** +- 1 x Raspberry Pi Zero 2 W (with soldered GPIO header) +- 1 x Breadboard +- 1 x LED +- 1 x 330Ω Resistor +- 1 x Push Button +- Jumper Wires + +**Circuit:** +1. **LED:** Connect the longer leg to a 330Ω resistor, and the other end of the resistor to GPIO 17. Connect the shorter leg to GND. +2. **Button:** Connect one leg to GPIO 2 and the other leg to GND. + +**Code (`headless_button.py`):** +```python +from gpiozero import LED, Button +from signal import pause + +# Initialize the LED on GPIO 17 +led = LED(17) + +# Initialize the Button on GPIO 2 +# The internal pull-up resistor is enabled by default +button = Button(2, pull_up=True) + +print("Program is running. Press the button to toggle the LED.") +print("Press Ctrl+C in the terminal to exit.") + +# The toggle() function flips the state of the LED +button.when_pressed = led.toggle + +# pause() keeps the script running in the background +pause() +``` + +**How it Works:** +1. SSH into your Pi Zero 2 W. +2. Run the script: `python headless_button.py` +3. The script will run in the foreground. You can now press the physical button connected to your Pi, and the LED will turn on and off. The `pause()` function is essential for keeping the script alive to listen for button presses. + +``` \ No newline at end of file