Arduino is a mini-computer used to control various electronic devices and create projects, functioning through a microcontroller that runs user-written code. It features digital and analog pins for controlling and reading devices, supports Pulse Width Modulation (PWM) for simulating analog outputs, and is programmed using the Arduino IDE. Applications of Arduino include smart homes, educational projects, and automation in various industries.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views54 pages
Arduino
Arduino is a mini-computer used to control various electronic devices and create projects, functioning through a microcontroller that runs user-written code. It features digital and analog pins for controlling and reading devices, supports Pulse Width Modulation (PWM) for simulating analog outputs, and is programmed using the Arduino IDE. Applications of Arduino include smart homes, educational projects, and automation in various industries.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54
What is Arduino?
•Arduino is like a mini-
computer that you can use to control lights, sounds, and even robots! •It helps us learn how to create cool electronic projects. •Think of it as a tool to bring your ideas to life! Parts of an Arduino Board Microcontroller (ATmega328P) • This is the brain of the Arduino Uno. • It runs the code you write and controls the connected devices. • Think of it as the decision- maker for your projects. Power Supply • The Arduino Uno needs 5-12 volts of input power, but it works best at 9V. • It can also be powered via USB (5V). • The board consumes around 50-200 mA of current depending on the project. Digital Pins • There are 14 digital pins (labelled 0-13). • These can be used to control devices like LEDs or read button presses. • Some pins support Pulse Width Modulation (PWM) for simulating analog output. When to Use Digital Pins • Use digital pins when you need to turn something ON or OFF, like lights or a motor. • They are great for devices that have two states (e.g., ON/OFF, HIGH/LOW). • Example: Controlling an LED to blink. Analog Pins • There are 6 analog pins (labelled A0-A5). • These read data like temperature, light intensity, or sound levels. When to Use Analog Pins • Use analog pins when you need to measure a range of values, like temperature or light intensity. • They are used to read data from sensors that provide varying outputs. • Example: Reading the brightness of light using a light sensor. What is PWM (Pulse Width Modulation) • PWM is a way to simulate analog output using digital pins. • Digital pins can only be HIGH (5V) or LOW (0V). PWM creates a signal that switches between HIGH and LOW very quickly. • By adjusting the time the signal stays HIGH vs. LOW, we can control the brightness of an LED or the speed of a motor. • Example: • If the signal is HIGH 50% of the time and LOW 50% of the time, the LED will appear dim. • If the signal is HIGH 90% of the time, the LED will appear brighter. • Pins with PWM capability are marked with a tilde "~" symbol on the Arduino board. USB Port • Used to upload your code to the Arduino. • It also powers the Arduino when connected to a computer. Reset Button • If something goes wrong, press this button to restart the program on your Arduino. Voltage Regulator • Ensures that the power supply to the Arduino stays safe and stable. • Protects the board from receiving too much voltage. Power Pins • VIN Pin: For connecting external power sources. • 3.3V Pin: Provides 3.3 volts to sensors and modules. • 5V Pin: Provides 5 volts to other components. • GND Pins: Connect to the ground of your circuit. Built-in LEDs • The "L" LED is connected to pin 13 and can be used to test simple programs. • The power LED shows if the board is ON. Crystal Oscillator • Keeps the Arduino’s timing accurate for running programs. What Can You Do With Arduino? • Light Control: Turn lights ON and OFF automatically. • Smart Alarms: Create alarms that buzz when someone enters a room. • Weather Sensors: Measure temperature, rain, or light. • Robots: Make robots that move and follow commands. • Games: Design simple games like reaction timers. How is Arduino Used in Real Life? • Smart Homes: Control lights, fans, and appliances automatically. • Schools: Create science projects like plant watering systems. • Hospitals: Monitor heartbeats and other health signals. • Factories: Automate machines and track production. • Everyday Fun: Build toys, musical instruments, or even your own gadgets. How Does Arduino Work? 1.Write instructions on a computer (called coding). 2.Send the code to the Arduino using the USB cable. 3.Connect wires, sensors, or lights to the Arduino. 4.Watch your project come to life! What is Arduino IDE? • To program Arduino, we use special software called Arduino IDE. • IDE stands for "Integrated Development Environment." • It's a software where you write the code for Arduino. • It helps to upload the code to the Arduino board. Structure of an Arduino Program void setup() • This is where you write the code that runs once when the Arduino starts. • Use it to set things up, like telling the Arduino which pins are inputs or outputs. void loop() • This is where you write the code that runs over and over again. • Use it to make your Arduino do things repeatedly, like turning a light on and off. Important Commands • pinMode • digitalWrite • digitalRead • delay pinMode(pin, mode) • Sets a pin as INPUT or OUTPUT. digitalWrite(pin, value) • Sends a HIGH (on) or LOW (off) signal to a pin. digitalRead(pin) • Reads the value from an input pin (HIGH or LOW). What Do HIGH and LOW Mean? • HIGH: Turns something ON (5 volts). • LOW: Turns something OFF (0 volts). What Are INPUT and OUTPUT? • INPUT: To receive data, like a button press. • OUTPUT: To send data, like turning on an LED. Variable • In Arduino, variables can store numbers, letters, or even true/false information that your Arduino uses to perform tasks. • Think of a variable as a container or a drawer where you can store things. • Variables help your Arduino remember and use information • If you’re controlling an LED’s brightness, you can use a variable to store the brightness level. • If you’re making a robot, variables can help it keep track of time or distance. Data Types • int (integer) • float (floating-point number) • char (character) • String • bool (boolean) int (integer) • Stores whole numbers (no decimals). • It’s like a counting jar where you can only store whole candies, not broken ones. float (floating-point number) • Stores numbers with decimals. • Imagine measuring water in a bottle. You can have 3.5 liters, not just whole numbers. char (character) • Stores a single letter or symbol. • Think of writing initials on a box to label what’s inside. Only one letter fits. String • Store words or multiple characters. • It’s like writing a full name on a tag. bool (boolean) • Can only have two values: true or false • It’s like a light switch. It can either be ON(true) or OFF(false) Which is variable, data type and value?
int: This is the data type of the variable.
ledPin: This is the name of the variable.
= 1: This assigns the value 1 to the variable
ledPin. It means the pin number 1 is stored in ledPin. Points to remember Blink an LED • Connect +ve of LED to pin 13 and –ve to GND. Uploading Code
Make sure the correct board
and port are selected in the Arduino IDE before uploading your code.