Requirements For IoT Kit Etc
Requirements For IoT Kit Etc
To use all components of the IoT Kit efficiently, including Arduino Uno, NodeMCU ESP8266,
and Raspberry Pi 3 B, your computer system should meet the following unified
requirements:
1. Hardware Requirements
Processor: Intel Core i5 (or equivalent AMD Ryzen 5) or higher for multitasking and
handling IDEs for all devices.
RAM: Minimum 4 GB (8 GB recommended for handling larger projects and
simulations).
Storage: At least 20 GB of free space to accommodate IDEs, libraries, firmware, and
project files.
USB Ports:
o At least two USB 2.0 or higher ports for connecting Arduino and NodeMCU
simultaneously.
o One additional port or HDMI for interfacing with the Raspberry Pi.
Graphics Support: Basic integrated graphics are sufficient for IoT development.
SD Card Reader: For flashing OS onto microSD cards for Raspberry Pi.
Power Supply: Ensure a stable power source for all components, including
microcontrollers and the Raspberry Pi.
3. Software Requirements
Arduino Uno:
o Arduino IDE: Version 1.8.19 or higher for code development and uploading.
o USB Drivers: CH340 or default drivers for Arduino Uno.
NodeMCU ESP8266:
o Arduino IDE: Add ESP8266 Board Manager for NodeMCU compatibility.
o CP210x USB to UART Driver: For USB communication.
o PlatformIO (optional): Advanced IDE for NodeMCU.
Raspberry Pi 3 B:
1|Pag e
o Raspberry Pi Imager: For flashing Raspberry Pi OS onto a microSD
card.
o VNC Viewer: For remote desktop control.
o Putty: For SSH access.
o Python 3: Pre-installed on Raspberry Pi OS for scripting and development.
Shared Tools for All Devices:
o VS Code: Universal code editor for Python, C/C++, and other languages.
o Libraries and Extensions:
Arduino Library Manager.
Python pip for managing Python libraries like Flask, Requests, etc.
o Network Tools: MQTT Broker (e.g., Mosquitto) for IoT communication.
4. Networking Requirements
Wi-Fi Connectivity: Required for NodeMCU and Raspberry Pi to access the internet
and IoT platforms.
Ethernet Port: Optional for a more stable connection to Raspberry Pi.
6. Additional Accessories
Micro USB Cable: For NodeMCU and Raspberry Pi power and communication.
HDMI Cable: For Raspberry Pi display connection (optional).
Breadboard and Jumper Wires: For prototyping projects across all platforms.
Power Adapter: 5V, 2.5A for Raspberry Pi.
2|Pag e
Arduino Uno R3
The Arduino Uno is one of the most popular microcontroller boards in the world, widely
used for a variety of projects ranging from simple hobby electronics to advanced robotics
and IoT applications. It is an open-source platform based on the ATmega328P
microcontroller. Designed for beginners and professionals alike, it is a perfect blend of
simplicity, versatility, and functionality.
1. Ease of Use: The Arduino Uno is designed to make electronics accessible to anyone.
Its simple programming environment and abundant tutorials make it beginner-
friendly.
2. Community Support: Being open-source, it has a large community that provides
support, projects, and libraries to expand its functionality.
3. Versatility: It supports a wide range of sensors, actuators, and communication
modules, making it ideal for IoT, robotics, and automation.
4. Prototyping: Its modular and plug-and-play design allows quick prototyping of ideas.
Understanding the pin configuration of the Arduino Uno is essential for building projects
and interfacing with components. Below is a detailed explanation of its pins and
functionalities:
Power Pins:
3.3V & 5V: Provides voltage to external components like sensors and modules.
GND: Ground pins for completing circuits.
Vin: Input voltage for powering the board when not using the USB port.
3|Pag e
Digital I/O Pins (0-13):
Used for digital input (e.g., detecting a button press) and output (e.g., controlling
LEDs).
PWM Pins (~): Pins 3, 5, 6, 9, 10, and 11 can output PWM signals for controlling
devices like motors and LEDs.
Reads analog signals from sensors like temperature sensors and potentiometers.
Converts the analog signals into a digital value using a 10-bit ADC (Analog-to-Digital
Converter).
Communication Pins:
Serial (Tx and Rx): Pins 0 (Rx) and 1 (Tx) are used for UART communication.
SPI: Pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK) support SPI communication for
high-speed interfacing.
I2C: Pins A4 (SDA) and A5 (SCL) support I2C communication for connecting multiple
devices.
Reset Pin:
AREF Pin:
ICSP Header:
The USB port is used for programming and powering the board.
The power jack allows external power input (7-12V).
The pin diagram is the foundation for understanding how to connect the Arduino Uno to
various components and devices.
4|Pag e
Steps to Install Arduino IDE
The Arduino IDE (Integrated Development Environment) is the software required to write,
upload, and debug programs for the Arduino Uno. Follow these steps to install and set it up:
5|Pag e
Step 4: Launch the Arduino IDE
1. Open the Blink example from the IDE: File > Examples > Basics > Blink.
2. Click the Upload button (arrow icon) to upload the code to the board.
3. If successful, the onboard LED on pin 13 will blink, confirming that your setup is
working.
6|Pag e
NodeMCU ESP8266: Overview, Pin Diagram, and Software Setup
NodeMCU is an open-source development board and firmware based on the ESP8266 Wi-Fi
module, widely used for IoT projects. It integrates Wi-Fi connectivity, making it ideal for
controlling devices over the internet or creating smart systems.
Features
Applications
Home automation.
IoT dashboards and cloud integration.
Wi-Fi-enabled sensors and actuators.
Web-based control systems.
7|Pag e
Common Pin Usages
1. Download: Visit Arduino Official Website and download the latest version for your
OS.
2. Install: Follow the on-screen instructions to complete the installation.
8|Pag e
2. Go to Tools > Port and select the appropriate COM port for NodeMCU.
Python-Based Programming: Write and execute Python code directly on the NodeMCU.
Built-In REPL (Read-Eval-Print Loop): Interactive shell for testing and debugging.
Wi-Fi Support: Seamless integration for IoT communication.
File System: Stores Python scripts and other files on the internal flash memory.
Applications
The pin diagram remains the same as for Arduino IDE setup:
9|Pag e
Step 1: Install Python
1. Download: Visit Python Official Website and download the latest Python version.
2. Install: During installation, check the option to add Python to PATH.
1. Download the MicroPython firmware for ESP8266 from the MicroPython Downloads Page.
2. Put the NodeMCU into bootloader mode:
o Press and hold the Flash button while pressing the Reset button.
3. Erase the existing firmware:
4. esptool.py --port <COM_PORT> erase_flash
Replace <COM_PORT> with your NodeMCU's port (e.g., COM3 on Windows or /dev/ttyUSB0
on Linux/Mac).
Install a tool like PuTTY, Tera Term, or screen to access the MicroPython REPL.
10 | P a g e
Step 1: Creating a Script
Use tools like ampy or the IDE to upload the script to the board.
11 | P a g e
Using Raspberry Pi 3B for IoT Kit: Overview and Setup Guide
1. About Raspberry Pi 3B
Key Features
35, 37 PWM Pins Pulse Width Modulation for motor control, LEDs, etc.
Installing Raspberry Pi OS
12 | P a g e
3. Insert and Boot:
o Insert the microSD card into the Raspberry Pi, power it up, and connect
peripherals (monitor, keyboard, mouse).
IoT Connectivity: Built-in Wi-Fi and Bluetooth for seamless IoT integration.
Web Server: Host a Flask/Django-based web server for remote monitoring and control.
AI Integration: Use TensorFlow Lite or OpenCV for machine learning and computer vision
tasks.
Real-Time Data: Integrate with MQTT, HTTP, or WebSocket protocols for live data streaming.
13 | P a g e
1. Ultrasonic Sensor (HC-SR04)
About the Sensor:
The Ultrasonic Sensor (HC-SR04) is used for measuring distance by sending out a sound
pulse and measuring the time it takes for the echo to return. It is widely used in robotics and
object detection.
Use:
Used for distance measurements, object detection, and obstacle avoidance in robots and
automation systems.
The PIR (Passive Infrared) motion sensor detects infrared radiation from objects, such as
humans or animals, in its range. It is used to sense movement and trigger events in smart
systems.
14 | P a g e
Pins and Their Functions:
VCC: Connects to the power supply (5V or 3.3V, depending on the sensor).
OUT: Output pin, which goes HIGH when motion is detected and LOW when no
motion is detected.
GND: Connects to ground.
Use:
Ideal for security systems, motion-triggered lighting, and home automation to detect
movement.
The DHT11 sensor measures both temperature and humidity. It is a low-cost digital sensor
and is frequently used in weather stations, home automation, and environmental
monitoring systems.
15 | P a g e
Use:
The MQ-2 sensor is sensitive to various gases such as smoke, methane, LPG, and carbon
monoxide. It is used for gas leakage detection or monitoring air quality.
Use:
Perfect for smoke and gas leakage detection systems, air quality monitoring, and safety-
related projects.
16 | P a g e
5 - LCD with I2C Module
The LCD with I2C is a 16x2 character LCD (Liquid Crystal Display) with an integrated I2C
module. It simplifies the wiring and reduces the number of pins required for the LCD to
function, as the I2C module uses only two data pins (SDA and SCL) for communication,
instead of the usual 6-10 pins for a standard parallel LCD.
The 16x2 refers to a display with 2 rows and 16 characters in each row. The I2C (Inter-
Integrated Circuit) module allows you to control the LCD with fewer wires, making it ideal
for use in IoT and embedded systems projects.
Use:
The LCD with I2C is widely used for displaying output in embedded systems, IoT projects,
and robotics. It is commonly used in:
Working Principle:
The I2C interface allows the microcontroller to communicate with the LCD display using only
two wires (SDA and SCL), which carry data and clock signals, respectively. The I2C bus
17 | P a g e
reduces the number of pins needed, making it more efficient for projects with
limited space and I/O pins.
SDA (Serial Data Line): This line is used for sending data to and receiving data from
the display.
SCL (Serial Clock Line): This line provides the clock signal to synchronize the data
transmission.
VCC and GND are connected to the power and ground of the system.
By using I2C, you can control the LCD with fewer pins compared to using the standard
parallel interface, making it more versatile for projects with limited microcontroller pins.
Implementation:
To use the LCD with I2C in your project, you will typically follow these steps:
6 - Buzzer
The buzzer is a simple electronic component that produces sound when an electrical signal
is applied. It is commonly used in IoT projects for providing auditory feedback or alerts when
specific conditions are met (like sensor detection, system status, etc.).
Your IoT kit uses a 4-pin buzzer, which likely consists of the following pins:
18 | P a g e
Buzzer Pin Configuration:
VCC (5V): Connect this pin to the 5V pin of the microcontroller (e.g., Arduino,
NodeMCU, or Raspberry Pi).
GND: Connect this pin to the ground (GND) of the microcontroller.
DATA (Signal): This pin is used to send a HIGH/LOW signal from the microcontroller
to control the buzzer.
7 - 4x4 Keypad
The 4x4 Keypad is an essential component in your IoT kit that allows users to input data in
the form of button presses. It is arranged in a matrix format with 16 push buttons (4 rows
and 4 columns). The keypad provides a simple and effective way to get numerical or
alphabetic input for various applications in your IoT projects.
Each of the 16 buttons is located at the intersection of a row and a column. When a button
is pressed, it connects one of the rows with one of the columns, sending a signal to the
microcontroller.
R1, R2, R3, R4: These are the row pins. They are connected to the microcontroller's
digital input pins.
C1, C2, C3, C4: These are the column pins. They are also connected to the
microcontroller's digital input pins.
19 | P a g e
When a button is pressed, the microcontroller checks which row and column are
connected, allowing it to determine which key was pressed.
The 4x4 Keypad can be used in various IoT applications, such as:
In this diagram:
Rows (R1, R2, R3, R4): These are connected to the microcontroller’s input pins.
Columns (C1, C2, C3, C4): These are connected to the microcontroller’s input pins as
well.
20 | P a g e
8 - Red LED
In your IoT kit, the 10 Red LEDs (L1 to L10) are essential components used to display visual
signals or alerts. LEDs (Light Emitting Diodes) are commonly used in various electronic
applications, including IoT systems, as indicators for the status of devices or operations.
Red LEDs (L1 to L10): These LEDs can be used for various purposes such as:
o Indicating the status of a device (ON/OFF).
o Showing alerts or notifications (e.g., system errors or activity).
o Visual indicators for sensors or communication.
o Representing different states in an IoT system (e.g., "Waiting", "Running",
"Error").
Anode (+): The positive side of the LED, which connects to the output pin of the
microcontroller or IoT device.
Cathode (-): The negative side, which is connected to the ground (GND) internally in
your IoT kit.
All 10 Red LEDs in your kit are internally connected to the ground (GND). This
simplifies the setup process as you do not need to wire them individually to GND,
saving time and effort.
Controlling LEDs: The microcontroller controls the Red LEDs by sending a HIGH or
LOW signal to their anode pin.
o HIGH (5V): The LED turns ON.
o LOW (0V): The LED turns OFF.
This on/off behavior is controlled programmatically using digital output pins on the
microcontroller.
Current Limiting: Each LED typically requires a current-limiting resistor (often 330Ω
or 220Ω) to prevent damage to the LED and ensure proper functioning. The resistor
is often included in the circuit, especially for each LED's anode pin.
21 | P a g e
Applications in IoT Projects
These Red LEDs can be used in several ways within your IoT projects:
+------------------------------------+
| |
( Anode ) ( Cathode )
| |
Microcontroller Pin GND (Internally
connected)
+-----------------------+
| Red LED (L1-L10)
+-----------------------+
In this diagram:
The Anode (positive side) of the LED is connected to the microcontroller's output
pins.
The Cathode (negative side) is connected to GND internally within your IoT kit.
An RGB LED is essentially a combination of three individual LEDs (Red, Green, and Blue) in a
single package. By adjusting the intensity of each of these LEDs, you can create a full
spectrum of colors. The primary purpose of an RGB LED in your IoT kit is to:
22 | P a g e
Display Status: Indicate different states (e.g., system running, error, or idle)
using various colors.
User Feedback: Provide visual feedback based on sensor input or system
performance (e.g., green for success, red for error).
Color-coded Alerts: Show different system conditions with different colors.
In your kit, the RGB LED is likely a common cathode type, meaning the common pin is
connected to GND.
The RGB LED works by varying the voltage sent to each of the red, green, and blue pins to
create different color combinations. The color is created by mixing different intensities of
the three primary colors (red, green, and blue).
Red Color: Turn on the red LED and keep the green and blue LEDs off.
Green Color: Turn on the green LED and keep the red and blue LEDs off.
Blue Color: Turn on the blue LED and keep the red and green LEDs off.
Mixed Colors: By combining the red, green, and blue intensities, you can generate
different colors:
o Yellow: Red + Green.
o Cyan: Green + Blue.
o Magenta: Red + Blue.
o White: Red + Green + Blue at full intensity.
The RGB LED in your IoT kit can be used for a variety of purposes:
23 | P a g e
Status Indicators: Use the RGB LED to show different system states (e.g.,
green for success, red for error, blue for idle).
User Notifications: Provide visual alerts based on sensor readings (e.g., temperature
or humidity levels).
Multi-color Feedback: Show user input or sensor readings in different colors,
providing dynamic feedback for system operations.
+-------------------------+
| | |
R Pin G Pin B Pin
| | |
Common Cathode (GND)
In this diagram:
R Pin (Red): Connects to a microcontroller's output pin for controlling the red light
intensity.
G Pin (Green): Connects to another microcontroller pin for controlling the green light
intensity.
B Pin (Blue): Connects to another microcontroller pin for controlling the blue light
intensity.
Common Cathode (GND): This is the shared ground for the RGB LED, which is
connected to the GND pin of the microcontroller.
1. Vcc1 (Pin 16): Connect to the 5V output from your IoT kit. This powers the logic
circuitry of the L293D motor driver.
2. Vcc2 (Pin 8): This is the motor power supply. Connect this pin to your 12V input for
the motor to work. It powers the motor.
3. GND (Pin 4, Pin 5, Pin 12, Pin 13): Connect these pins to the Ground (GND) of your
IoT kit. These pins are required for proper operation of the L293D IC.
4. IN1, IN2 (Pins 2 and 7): These pins are used to control Motor 1 direction. By setting
these pins HIGH or LOW, you can control the direction of rotation of Motor 1:
24 | P a g e
o IN1 = HIGH, IN2 = LOW: Motor 1 rotates in one direction (clockwise
or counterclockwise).
o IN1 = LOW, IN2 = HIGH: Motor 1 rotates in the opposite direction.
5. IN3, IN4 (Pins 10 and 15): These pins are used to control Motor 2 direction. Similarly,
set these pins to HIGH or LOW to control the direction of rotation of Motor 2.
6. OUT1, OUT2 (Pins 3 and 6): These are the output pins for Motor 1. Connect these to
the terminals of Motor 1.
o OUT1 connects to the positive terminal of Motor 1.
o OUT2 connects to the negative terminal of Motor 1.
7. OUT3, OUT4 (Pins 11 and 14): These are the output pins for Motor 2. Connect these
to the terminals of Motor 2.
o OUT3 connects to the positive terminal of Motor 2.
o OUT4 connects to the negative terminal of Motor 2.
1. Motor Power: The L293D is designed to work with both 5V and 12V supplies. The 5V
is used for logic circuitry, and the 12V is used to power the motors connected to
OUT1, OUT2, OUT3, OUT4.
2. Motor Direction Control: The inputs IN1, IN2 (for Motor 1) and IN3, IN4 (for Motor
2) are used to set the direction of the motors. By changing the states of these pins,
you can make the motors rotate clockwise or counterclockwise.
3. PWM Control: Speed control can be achieved through Pulse Width Modulation
(PWM) applied to the Enable pins (if connected). This controls the power delivered
to the motors, thus adjusting their speed.
Practical Example
Let’s assume you have two DC motors (Motor 1 and Motor 2) connected to the L293D IC.
Here’s how you can control their movement:
25 | P a g e
1. Motor 1 Control:
o IN1 = HIGH, IN2 = LOW → Motor 1 rotates in one direction (clockwise or
counterclockwise).
o IN1 = LOW, IN2 = HIGH → Motor 1 rotates in the opposite direction.
2. Motor 2 Control:
o IN3 = HIGH, IN4 = LOW → Motor 2 rotates in one direction.
o IN3 = LOW, IN4 = HIGH → Motor 2 rotates in the opposite direction.
By appropriately setting these input pins, you can control the direction of both motors in
your robot or automated system.
Dual Motor Control: The L293D motor driver can independently control two motors.
Current Amplification: It amplifies the low current from the microcontroller to drive
the motors.
Bidirectional Control: The H-Bridge technology allows the motors to rotate in both
clockwise and counterclockwise directions.
Speed Control: By using PWM on the enable pins, you can also control the speed of
the motors.
1. VCC:
o Power supply pin.
o Connect to 3.3V or 5V depending on your microcontroller.
2. GND:
o Ground pin.
o Connect to the GND of your microcontroller.
3. RX (Receive):
o Receives data from the microcontroller's TX (Transmit) pin.
o Requires a voltage divider (if using 5V microcontrollers like Arduino UNO) to
avoid damage as the HC-05 operates on 3.3V logic.
4. TX (Transmit):
o Sends data to the microcontroller's RX (Receive) pin.
26 | P a g e
Key Features
Applications
Working Principle
Advantages
27 | P a g e
The HC-05 (4-pin) module is a compact and efficient solution for integrating
Bluetooth communication into IoT systems, offering flexibility and convenience in
wireless connectivity.
Pin Configuration
1. VCC:
o Power input for the relay module (usually 5V).
o Connect to the 5V pin of your microcontroller.
2. GND:
o Ground connection.
o Connect to the GND of your microcontroller.
3. IN1:
o Signal input to control Relay 1.
o Connect to the microcontroller GPIO pin.
4. IN2:
oSignal input to control Relay 2.
oConnect to the microcontroller GPIO pin.
5. COM (Common):
o Common terminal of the relay.
o Used for connecting the high-voltage circuit.
6. NO (Normally Open):
o Connect here if the circuit should be off by default and turn on when the
relay is activated.
7. NC (Normally Closed):
o Connect here if the circuit should be on by default and turn off when the
relay is activated.
28 | P a g e
Working Principle
The relay module uses an electromagnetic coil to open or close the connected
circuit.
A low-level signal from the microcontroller (e.g., 3.3V or 5V) energizes the coil.
This activates the switch, allowing the connected high-voltage device to operate.
Applications
Home Automation:
o Control appliances like lights, fans, and air conditioners.
IoT Systems:
o Remotely switch devices on and off using apps like Blynk or Sinric Pro.
Industrial Automation:
o Manage machinery or motors in factories.
Robotics:
o Operate high-power actuators or devices in robotic systems.
Advantages
The 2-channel relay module is a versatile and essential component for IoT and embedded
systems, providing an effective solution for controlling high-power devices in a safe and
efficient manner.
1. Arduino Uno R3
Testing:
Upload a simple Blink program to test the Arduino board's functionality.
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Onboard LED pin
}
void loop() {
29 | P a g e
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
2. NodeMCU ESP8266
Testing:
Upload a basic Wi-Fi connection code using the Arduino IDE.
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("\nConnecting to Wi-Fi...");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nConnected!");
}
void loop() {}
Testing:
Display a test message on the LCD.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
void setup() {
lcd.begin();
lcd.backlight();
lcd.print("Hello, IoT Kit!");
}
void loop() {}
30 | P a g e
Testing:
Display temperature and humidity readings on the Serial Monitor.
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Temp: ");
Serial.print(temp);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000);
}
Testing:
Measure distance using the sensor.
#define TRIG 9
#define ECHO 10
void setup() {
Serial.begin(9600);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
}
void loop() {
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(1000);
31 | P a g e
}
Testing:
Detect motion and print the result in the Serial Monitor.
#define PIRPIN 7
void setup() {
Serial.begin(9600);
pinMode(PIRPIN, INPUT);
}
void loop() {
int motion = digitalRead(PIRPIN);
if (motion) {
Serial.println("Motion Detected!");
} else {
Serial.println("No Motion.");
}
delay(1000);
}
Testing:
Send and receive data via Serial Monitor and Bluetooth.
void setup() {
Serial.begin(9600);
Serial.println("Bluetooth Test - Send Data");
}
void loop() {
if (Serial.available()) {
char data = Serial.read();
Serial.print("Received: ");
Serial.println(data);
}
}
Testing:
Control one channel of the relay.
#define RELAYPIN 8
void setup() {
32 | P a g e
pinMode(RELAYPIN, OUTPUT);
}
void loop() {
digitalWrite(RELAYPIN, HIGH);
delay(1000);
digitalWrite(RELAYPIN, LOW);
delay(1000);
}
Testing:
Run a DC motor forward and backward.
#define IN1 3
#define IN2 4
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
}
void loop() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
delay(2000);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
delay(2000);
}
Testing:
Make the buzzer beep.
#define BUZZERPIN 11
void setup() {
pinMode(BUZZERPIN, OUTPUT);
}
void loop() {
digitalWrite(BUZZERPIN, HIGH);
delay(500);
digitalWrite(BUZZERPIN, LOW);
delay(500);
}
33 | P a g e
11. 10 Red LEDs (L1 to L10)
Testing:
Blink all LEDs sequentially.
void setup() {
for (int i = 0; i < 10; i++) {
pinMode(leds[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < 10; i++) {
digitalWrite(leds[i], HIGH);
delay(200);
digitalWrite(leds[i], LOW);
delay(200);
}
}
Testing:
Change the RGB LED color.
#define REDPIN 3
#define GREENPIN 5
#define BLUEPIN 6
void setup() {
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
}
void loop() {
analogWrite(REDPIN, 255);
analogWrite(GREENPIN, 0);
analogWrite(BLUEPIN, 0);
delay(1000);
analogWrite(REDPIN, 0);
analogWrite(GREENPIN, 255);
analogWrite(BLUEPIN, 0);
delay(1000);
analogWrite(REDPIN, 0);
analogWrite(GREENPIN, 0);
analogWrite(BLUEPIN, 255);
delay(1000);
34 | P a g e
}
Testing:
Print pressed keys in the Serial Monitor.
#include <Keypad.h>
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}
35 | P a g e