0% found this document useful (0 votes)
25 views12 pages

Ctechq 4

The document provides an overview of digital and analog pins in Arduino, detailing their functions, including Pulse Width Modulation (PWM) capabilities. It also covers the use of multimeters for testing components like LEDs and resistors, and explains the basic structure and programming functions of Arduino. Additionally, it discusses various types of switches and their applications in circuits.

Uploaded by

shamyesteban
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views12 pages

Ctechq 4

The document provides an overview of digital and analog pins in Arduino, detailing their functions, including Pulse Width Modulation (PWM) capabilities. It also covers the use of multimeters for testing components like LEDs and resistors, and explains the basic structure and programming functions of Arduino. Additionally, it discusses various types of switches and their applications in circuits.

Uploaded by

shamyesteban
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DIGITAL AND ANALOG PINS

Digital Pins Analog Pins Pulse Width Modulation


(PWM) Pins
-Marked as D0 to D13 -Analog pins, unlike digital pins, -Indicated by a tilde (~) next
-Used for digital signals, which do not directly support Pulse to them.
are either HIGH (1) or LOW (0). Width Modulation (PWM). -Simulate analog output by
-Can be used for input (reading Instead, they are primarily used rapidly switching between
digital sensors like buttons) or for reading continuous (analog) HIGH and LOW.
output (controlling LEDs, motors, voltage values.
etc.).
-Some digital pins support Pulse
Width Modulation (PWM),
simulating an analog output by
rapidly switching between HIGH
and LOW.

digitalWrite()
- Is a function that is fundamental command used to control digital output pins.
- digitalWrite(13, HIGH); // Turns on LED at pin 13

pinMode(pin, mode);

- Sets a pin as INPUT, OUTPUT, or INPUT_PULLUP.


- pinMode(13, OUTPUT);

void setup() { }

- Runs once when the Arduino starts.


- Used for initial setup (defining pin modes).

4. void loop() { }

- Runs continuously as long as the Arduino is powered on.

- void loop()
{ digitalWrite(13,
HIGH); // Turn LED ON delay(1000); // Wait 1
second digitalWrite(13, LOW); // Turn
LED OFF delay(1000); // Wait 1 second}

The delay() function in Arduino pauses the execution of the code for a specified amount of time,
measured in milliseconds.
1. What type of signal can take on any value within a range? Analog Signal
2. What function is used to set a digital pin as INPUT or OUTPUT? pinMode()
3. Which type of pins are marked as D0 to D13? Digital Pins
4. What does the tilde (~) symbol next to some digital pins indicate? (PWM)
5. Which function is used to control the state of a digital pin? digitalWrite()
6. What function reads an analog input value from a pin? analogRead()
7. Which function runs continuously as long as the Arduino is powered on? void loop()
8. What kind of signal do PWM pins simulate by rapidly switching between HIGH and LOW?
Analog Output
9. What command turns on an LED connected to pin 13? digitalWrite(13, HIGH);
10. Which type of pins are marked as A0 to A5? Analog Pins

MULTIMETER

Parts of an LED and Their Functions

 Anode (+) – The longer leg, connected to the positive voltage.


 Cathode (-) – The shorter leg, connected to ground.
 Semiconductor Material – Emits light when current flows through it.

Multimeter Basics

A multimeter is an electronic measuring instrument that combines multiple functions.

Modes Used:

 Voltage (V) Mode – Measures voltage levels.


 Resistance (Ω) Mode – Measures resistance in ohms.
 Diode Mode – Tests LEDs and diodes.
 Continuity Mode – Checks if there is an electrical connection.

Resistors

- Measured in Ohms (Ω).


- Function: Limits or regulates the flow of current.
- Used for: Voltage division, Current limitation, Signal control

How to Use a Multimeter

1. Testing an LED

- Use Diode Mode.


- Connect the red probe to the anode and the black probe to the cathode.
- A working LED will light up slightly or show a small voltage reading.

2. Testing a Resistor
- Use Resistance (Ω) Mode.
- Place probes on both ends of the resistor.
- A working resistor will show a measured resistance value.

Reference LED Voltage Values

 Red: 1.6–2.2 V
 Orange: 2.0–2.4 V
 Yellow: 2.1–2.2 V
 Green: 1.9–4.0 V
 Blue: 2.4–4.0 V
 Clear White: 3.5 V

1. Which multimeter mode is used to test an LED? Diode mode


2. What should happen when testing a working LED in diode mode? The LED will light up slightly
or show a small voltage reading
3. What is the correct way to measure the resistance of a resistor? Set the multimeter to
Resistance (Ω) mode and place probes on both ends of the resistor
4. What does an infinite (OL) reading on the multimeter mean when testing a resistor? The
resistor is open or faulty
5. Why is it important to test an LED or resistor before using it in a circuit? To ensure the
component is functional and avoid circuit failure

PWM
Arduino - is an open-source microcontroller platform that allows users to interact with electronic
components through programming.
Microcontroller - is a compact integrated circuit designed to execute specific tasks by processing
inputs and generating outputs.
Arduino communicates with electronic parts using its pins. These pins can either send or receive
signals, depending on whether they’re digital (on or off) or analog (varying levels).

Digital Pins (High/Low Signal)


Used for turning components ON or OFF
(e.g., LEDs, motors,buzzers).
Function:
digitalWrite(pin, HIGH/LOW);
Analog Pins (Variable Input Values)
Reads continuous data from sensors like temperature, light, or pressure.
Function:
analogRead(pin);
PMW Pins (Pulse Width Modulation)
Simulates analog output to control brightness (LEDs) or speed (motors).
Function:
analogWrite(pin, value);
Conclusion:
Arduino acts as a microcontroller that bridges software and hardware, enabling electronic
components to interact through simple programming.
Arduino IDE:
The Arduino IDE is the main software used to write, check, and send code to Arduino boards. It acts
as the link between the programmer and the hardware.
Key Features:
 Code Editor
 Compiler and Debugger
 Board Manager
 Library Manager
 Serial Monitor
Importance of the Arduino IDE:
 It simplifies coding for beginners with an easy-to-use interface.
 It allows students to test and debug their programs efficiently.
 It supports multiple Arduino boards, making it versatile.
 The open-source community provides extensive resources and libraries.
PMW - Pulse Width Modulation (PWM) is a technique used to simulate an analog output using
digital signals.
Duty Cycle - The duty cycle of a PWM signal is the percentage of time the signal stays HIGH during
one complete cycle.

If the duty cycle is:


100% - The output is always HIGH (fully ON)
50% - The signal is HIGH half the time and LOW half the time
0% - The output is always LOW (fully OFF)
analogWrite():
The analogWrite(pin, value) function is used to generate a PWM signal on specific PWM-capable
pins.
1. Takes two parameters:
1.1 Pin – where the signal is generated
1.2 Value – a number from 0 to 255
Example of Code:
int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);}
void loop() {
analogWrite(ledPin, 128);
delay(1000);
analogWrite(ledPin, 255);
delay(1000);}
Parts of LED

 Epoxy Lens
-a clear, dome-shaped cover that acts as a lens, protecting the LED chip and focusing its
light output, while also providing structural stability and vibration resistance (Google).
 LED chip
- produce light when electricity flows. It is a small semiconductor component that create
light when the electric current passes through it, forming the core of an LED light bulb.
 Bond Wire
-It is a thin wire that provides an electrical connection between the LED chip and the
external circuit.
 Reflective Cavity
-a reflective material surrounding the semiconductor die that directs light outwards towards
the lens, improving efficiency and light output.
-enhance light output.
 Anode (+)
-Longer Leg
-Connect to a PWM-capable digital pin or any digital pin.
 Cathode (-)
-Shorter Leg
-Connect to the GND (Ground) pin of the Arduino.
PIEZZO BUZZER
Piezo Buzzer - A piezo buzzer is a small electronic component commonly used to generate sound in
Arduino projects.

 A piezo buzzer is a small device that makes sound


using a special material that vibrates when electricity
passes through it. This material is placed between two
metal plates, which help produce the sound you hear.
 The main function of a piezo buzzer in Arduino is to
produce different tones and melodies.
 The main function of a piezo buzzer in Arduino is to
produce different tones and melodies.
 The main function of a piezo buzzer in Arduino is to
produce different tones and melodies.
void setup()
{ pinMode (7, OUTPUT) ; }
void loop()
{ delay(500);
tone(7, 329, 100);
delay(700);
}

Code Function:
void setup()
{ pinMode (7, OUTPUT) ; }
-The setup() function is used to prepare everything before the main program starts running. It helps
set up important settings, like pin modes or initial values, so the program works correctly in the loop()
function.
-The pinMode() function in Arduino is used to configure a specific digital pin on the Arduino board as
either an input or an output.

void loop()
{tone(7, 329, 100);
delay(700);
}
-loop() function is to define the behavior and actions that need to be performed repeatedly or
continuously by the Arduino.
-tone(pin, frequency, milliseconds): This function generates a square wave of the specified frequency
on the given pin, causing the piezo buzzer to produce sound.
o Pin - refers to the digital pin number to which the piezo buzzer is connected.
o Frequency - This parameter represents the frequency of the tone to be played in hertz (Hz).
o Milliseconds - This parameter represents the duration or duration of the tone to be played in
milliseconds (ms).
MAJOR COMPONENTS OF ARDUINO UNO:
Reset Button - used to restart the microcontroller.
USB Port - The USB port uses a standard A-to-B USB cable, commonly found with printers and other
peripherals.
Power Port - The Arduino UNO board operates at a voltage of 5 volts, but it can withstand a
maximum voltage of 20 volts. The power port allows you to connect external power sources.
Voltage Regulator - A voltage regulator is a system designed to automatically maintain a constant
voltage.
USB Interface Chip - acts as a translator, converting the complex USB communication protocol into a
simpler serial communication format.
Crystal Oscillator -also called Ceramic Resonator. it is used to calculate the time.
Pins - The pins provide space for connecting wires to develop a circuit. Each of these pins is labeled.
These pins serve various functions. The number of pins may differ according to the type of board.
TX RX - The TX RX markings indicate the pins for serial communication. With these LEDs, users can
know when the board is transmitting or receiving data.
Microcontroller - It acts as the brain of the Arduino that stores and runs the code you upload via a
USB cable from your computer.
TRANSLATE CIRCUIT DIAGRAM INTO A FUNCTIONAL CIRCUIT
BreadBoard - A breadboard is a tool used for prototyping electronic circuits without soldering.
Circuit – use symbols to represent electronic components
Structure- a breadboard has a terminal rails and power strips
Main Parts:
Terminal Strips
 Holes are grouped in sets of five.
 Each set of five holes in a column is electrically connected.
 The middle gap separates two sides, useful for placing
Power Rails (Vertical Lines on the Sides)
o Marked with "+" (positive) and "-" (negative) symbols.
o Used to distribute power (Vcc and GND) across the board.
o Usually connected along the entire row.

Electrotic Symbols:

RESISTOR GROUND WIRE

CELL BATTERY BULB


BUZZER DIODE

UNDERSTANDING
DIGITALWRITE()
IN ARDUINO

 Void setup()
-This function runs once when the Arduino is powered on or reset.
-Example:
void setup()
{pinMode(13, OUTPUT)}

 pinMode()
-This function used to configure/read a specific digital pin as an INPUT, OUTPUT, or
INPUT_PULLUP.

 Void loop()
-This function repeats continuously as long as the Arduino is powered.
-Example:
void loop() {
digitalWrite(13, HIGH);
delay(1000)
digitalWrite(13, LOW);
delay(1000)}

SWITCH AND PUSHBUTTON


What is a Switch?
-A switch is an electrical device that is used to open or close a circuit, allowing or stopping the flow of
electricity.

TYPES OF SWITCHES
 Push Button Switch – An electrical switch that is used to control an electrical circuit by
physically pressing a button. A simple switch mechanism, typically made of plastic or metal,
that activates or deactivates something when pressed, For example, a Door Bell.
 Toggle - An electrical switch that pivots around one end of their actuator lever. For example, a
lever.

 Slide Switch - A mechanical switch that slides from the open (off) position to the closed (on)
position and allows control of a circuit's current flow without having to manually splice or cut
wire. For example, a switch to on a toy.
Rotary Switch - Is used to control multiple circuits by turning a knob or dial to different positions. a switch
operated by rotation. An example of this is the Safe / door to a bank safe.

TYPES OF PUSH BUTTON


 Normally Open (NO) Switch
-The circuit is open (off) until pressed.
-The switch is open, meaning the circuit is incomplete and current flows.
-The default mode of the LED is off / the button is not being pressed. But when the button is
pressed the light will shine and the current will flow.

 Normally Close (NC) Switch


-Circuit is closed (ON) until pressed
- The switch is closed meaning the circuit is complete and current flows.
- This switch is the vice-versa of the normally open switch. The default mode of the led is on /
the button is not being pressed. But when the button is pressed the LED will TURN OFF.
Hence the current was cut off.

 INPUT_PULLUP
-a mode used to configure a digital input pin with an internal pull-up resistor.
- particularly useful for ensuring a stable and defined state for the input pin when no external
signal is applied.
- When the button is not pressed, the pin reads HIGH. When you press the button, it connects
to ground and reads LOW
- Without INPUT_PULLUP: When the button is not pressed, the pin might randomly read HIGH
or LOW.

 CODE:
void loop() {
if (digitalRead(buttonPin) == LOW)
{ digitalWrite(ledPin, LOW); }
else
{digitalWrite(ledPin, HIGH);}
}

 digitalRead()
- A function in Arduino programming used to read the state of a digital input pin. It tells you
whether the pin is HIGH (5V or 3.3V) or LOW (0V).

- Purpose: To check if a digital pin is HIGH or LOW.


- Syntax: digitalRead(pin), where pin is the number of the pin you want to read.
- Reading Buttons or Switches: To check if a button or switch is pressed.
- Sensor Inputs: To read the state of digital sensors (e.g., motion sensors, limit switches).

 CODE:
void loop() {
if (digitalRead(buttonPin) == LOW)
{ digitalWrite(ledPin, LOW); }
else
{digitalWrite(ledPin, HIGH);}
}

1. LED with Push Button CODE:


const int push=12;
const int led=8;
void setup()
{pinMode(push,INPUT_PULLUP);
pinMode(led,OUTPUT);}
void loop()
{
if(digitalRead(push)== LOW)
{ digitalWrite(led, HIGH);}
else
{ digitalWrite(led, LOW);}

}
2. LED ( Only )

CODE:
void setup()
{
pinMode(2, OUTPUT); digitalWrite(4, LOW);
pinMode(4, OUTPUT); digitalWrite(7, HIGH);
pinMode(7, OUTPUT); delay(15000);
} digitalWrite(7, LOW);
void loop() }
{
digitalWrite(2, HIGH);
delay(15000);
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
delay(5000);

You might also like