[go: up one dir, main page]

0% found this document useful (0 votes)
5 views71 pages

Grade 9 Coding and Robotics

The document outlines a curriculum for Grade 9, focusing on programming concepts such as while loops, turtle graphics, data science, and artificial intelligence. It includes chapter indexes for coding and robotics, detailing activities and learning outcomes for each topic. Students will learn to automate tasks, create graphics, and understand data manipulation using Python programming.

Uploaded by

bharat
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
5 views71 pages

Grade 9 Coding and Robotics

The document outlines a curriculum for Grade 9, focusing on programming concepts such as while loops, turtle graphics, data science, and artificial intelligence. It includes chapter indexes for coding and robotics, detailing activities and learning outcomes for each topic. Students will learn to automate tasks, create graphics, and understand data manipulation using Python programming.

Uploaded by

bharat
Copyright
© © All Rights Reserved
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/ 71

CODING INDEX

CHAPTER NO. CHAPTER NAME PAGE NO.

1 Exploring New Horizon 3


2 While Loop 4
3 While loop-01 Activity 5
4 While loop-02 Activity 6
5 While loop-03 Activity 6
6 While loop-09 Activity 7
7 Appln-12 Activity 8
8 Turtle Programming 10
9 Turtle Basic Activity 11
10 Turtle Basic Activity 12
11 Turtle Basic Activity 13
12 Turtle While Activity 13
13 For-44 Activity 14
14 For-52 Activity 15
15 For-54 Activity 15
16 Introduction to Data Science 17

educobot.com 1
ROBOTICS INDEX

CHAPTER NO. CHAPTER NAME PAGE NO.

1 Revision of Basics 26
2 Active and Passive Components 26
3 Breadboard Circuit—Building And Gate 28
4 Breadboard Circuit—Or Gate / Not Gate 29
5 Introduction to IOT 33
6 Exploring IoT Dashboard on Innovator 34
7 IOT Based LED Light Control 37
8 IoT Weather Station with dht11 38
IoT Distance Management with Ultra-
9 40
sonic Sensor
10 Smart Garbage Monitoring with IoT 42
11 IoT Smart Bell With Access Control 46
12 Introduction to AI and ML 51
13 Introduction to Model Training 58
14 Smart House with AI 60
15 7 Segment Display with AI 65

educobot.com 2
EXPLORING NEW HORIZON

Welcome to Grade 9! This year, we're going to expand our computing skills and explore exciting
new areas, from controlling graphics with code to getting a taste of data science and artificial in-
telligence!

What We'll Do This Year:

We'll be diving into some powerful new tools and concepts:

• While Loops: You already know how to repeat actions with loops. This year, we'll learn about
while loops, which let us repeat actions until a certain condition is true. This is like saying, "Keep doing
this while this is happening." This will give us more con-
trol over how our programs run.
• Turtle Graphics: Get ready to draw with code!
We'll be using the Turtle library to create colorful
shapes, patterns, and even animations. You'll be able
to write code that tells a "turtle" (a little cursor) where
to move and what to draw.
• Introduction to Data Science: We'll get a
glimpse into the world of data science, where we use
computers to analyze and understand large amounts
of information. We'll learn how data scientists use pro-
gramming to find patterns and insights.
• NumPy and Pandas Libraries: We'll explore two important tools for data science: NumPy and
Pandas. NumPy helps us work with numbers efficiently, and Pandas helps us organize and analyze
data in tables, kind of like a spreadsheet.
• A Touch of AI: We'll explore some basic concepts of artificial intelligence (AI) and see how com-
puters can learn and make decisions. This will give you a first look at this exciting field.
• Coding Connections: Throughout the year, we'll see how all these concepts connect to cod-
ing. You'll be using your coding skills to control the Turtle, work with data, and even explore some
AI ideas.

Learning Outcomes:

By the end of the year, you will be able to:

• Use while loops to control the flow of your programs.


• Create graphics and animations using the Turtle library.
• Understand the basic concepts of data science.
• Use NumPy and Pandas for basic data manipulation.
• Get a first glimpse into the world of artificial intelligence.
• Apply your coding skills to create interesting projects that combine these new concepts.

Get ready for a year of exciting exploration! You'll be discovering new ways to use computers to
create, analyze, and learn!

educobot.com 3
WHILE LOOP

1.1 What will you learn in this chapter?

• What is While Loop?


• Who Invented it ?
• How does while loop work and its Syntax in
Python?
• Why are While loops important In coding?
• Activities based on While loop.

1.2 What is While loop?


A while loop in Python is used to repeat a block of code as long as a certain condition is true. It helps automate
repetitive tasks without writing the same code multiple times.

1.3 Who invented While loop?

The concept of loops, including the while loop, originates from early programming
languages developed in the 1950s and 1960s. , the creator of FORTRAN, introduced
structured programming concepts, which later influenced the development of loops.
Over time, languages like C, Java, and Python incorporated while loops as an essen-
tial feature for repetition and automation in programming.

1.4 How Does a While Loop Work?


1. The program checks a condition before running the loop.
2. If the condition is True, the code inside the loop executes.
3. After execution, the condition is checked again.
4. If the condition is still True, the loop continues.
5. Once the condition becomes False, the loop stops.

Syntax of While Loop in Python


while condition:

# Code to execute repeatedly

· The condition is checked before each iteration.

· If the condition is True, the loop runs.

· If the condition is False, the loop stops.

Example 1: Printing Numbers from 1 to 5


num = 1
while num <= 4:

print(num)
num += 1 # Increases num by 1 in each iteration

educobot.com 4
Output
1

4
Explanation:
• num = 1 The loop starts with num as 1.
• while num <= 5 The condition is checked before running the loop.
• Inside the loop, num is printed and then increased by 1.
• Once num reaches 6, the condition num <= 5 becomes False, and the loop stops.
1.5 Why Are While Loops Important in Coding?
• Automation: Reduces manual work by executing repetitive tasks.
• Dynamic Execution: Runs until a condition is met, making it useful for unknown repetitions.
• User Interaction: Keeps programs running based on user input (like login attempts).
• Game Development: Used for real-time loops in video games (like player movements).

1.6 Activities based on While Loop

WHILE LOOP-01

Task: In this lesson, we will use print() function to display Hello 5 time on the output screen.

This activity will demonstrate the importance


of the while loop by printing "Hello" five times
using the print function. This is a guided les-
son, meaning the code will be provided as
placeholders for support. If you make a mis-
take while typing, the incorrect part will turn
red, indicating an error that you need to fix.

Output of the above code

educobot.com 5
WHILE LOOP-02
Task: In this lesson, we will use While loop to our previous code instead of printing it separately for 5 time
and understand how While loop can make our task easier.

This activity highlights the sig-


nificance of the while loop by
printing "Hello" five times using a
loop. Instead of calling the print
function multiple times, we use
a while loop to simplify the task

if i is not incremented, the con-


dition i <= 5 will always remain
true, causing an infinite loop.
Incrementing i ensures the loop
eventually stops when i ex-
ceeds 5.

We got the same output as


previous code but this time
using while loop.

WHILE LOOP-03

educobot.com 6
Task: In this lesson, we will use While loop to our previous code instead of printing it separately for 5 time.

The image shows a debugging les-


son where you need to find and fix a
bug in a while loop. The code at-
tempts to print "Hello", but an issue
in the loop condition or increment
may cause an infinite loop or an er-
ror. You need to analyze and cor-
rect the mistake for proper execu-
tion.

The image shows a debugging


lesson where you need to iden-
tify and fix an error in a while
loop. The error message on the
right indicates that the variable i
is not defined, causing a
NameError. You need to initial-
ize i before using it in the loop
to fix the issue.

In this image, after three unsuccess-


ful attempts to debug the code,
the AI assistant pops up and asks
if you need any help. If you ac-
cept, it identifies the issue—using
the variable i without initializa-
tion—and explains why it causes
a NameError. The AI then pro-
vides the corrected code along
with a summary to help you un-
derstand the fix.

WHILE LOOP-09

Task: In this lesson, we will use While loop along with condition to check whether numbers from 0 to 5 are
lesser than 5 or not

educobot.com 7
In this activity, we will use a
while loop and a condition to
check whether numbers from
0 to 5 are less than 5. If the
condition is true, we will print
[number] is less than 5.

If the condition is false which


means the number is not less
than 5 then we will print
[number] is not less than 5.

We used a while loop to check


if numbers from 0 to 5 are less
than 5.

• It starts with i = 0 and runs


the loop while i <= 5.
• Inside the loop, if i is less
than 5, it prints "i is less than
5" and increments i by 1.
• The else part prints "i is not
less than 5" when i reaches
5.
The output shows numbers 0 to
4 as "less than 5" and 5 as "not
less than 5".

APPLN-12

Task: In this lesson, we will use While loop to make a dice roll and get a random output.

Rolling two dice using a while loop. This keeps


rolling the dice (generating random numbers
between 1 and 6) as long as the user inputs
"yes". The random library will generate random
numbers.

educobot.com 8
The code simulates rolling
two dice using a while loop. It
continues rolling as long as
the user inputs "yes." Howev-
er, there is an error: randint
(i,6) should be randint(1,6)
since i is not defined.

The code simulates rolling two


dice using a while loop. It
keeps rolling as long as the
user inputs "yes." The program
prints the dice values and then
asks the user if they want to
roll again.

QUIZ TIME

Q1. What is the purpose of a while loop in Python?


To execute a block of code a fixed number of times
To execute a block of code as long as a condition is true
To iterate over a sequence like a list or tuple

Q2. What happens if the condition in a while loop is always True?


The loop will execute only once

The loop will run indefinitely (infinite loop)


The loop will never run

Q3. What happens if you forget to update the loop variable inside a while
loop?
The loop executes only once

The loop never executes


The loop runs forever (infinite loop)

The program throws an error

educobot.com 9
SHORT ANSWER QUESTIONS
Q1. What is while loop used for in Python?
Q2. Can a while loop have an else statement? If yes, when does it execute?
Q3. Write a simple while loop that prints numbers from 1 to 5.

TURTLE PROGRAMMING

2.1 What will you learn in this chapter?

• What is Turtle Programming?


• Features of Turtle Module
• Basic Concepts in Turtle Programming
• Drawing Shapes with Turtle
• Loops in Turtle Programming

2.2 What is Turtle Programming?

Python's Turtle module provides a simple way to draw


graphics and create visual programs. It is widely used
for introducing programming concepts such as loops,
functions, and event handling .Turtle programming
was inspired by the Logo programming language,
which was invented by Seymour Papert and his team
at the Massachusetts Institute of Technology (MIT) in
1967.

Logo was designed as an educational programming


language to help children learn coding and mathe-
matics through visual representation. The "turtle" in
Logo was originally a robot that moved on the floor,
following commands from the program. Later, it was
adapted into a graphical version, which became the
basis for Python’s Turtle module.

2.3 Features of Turtle Module

· Graphical Output: Draw lines, shapes, and patterns.

· Event Handling: Control the turtle using keyboard and mouse inputs.

· Looping & Functions: Create complex drawings with loops and functions.

· Interactive Programming: Allows users to interact with the program.

educobot.com 10
2.3 Basic Concepts in Turtle Programming
(a) The Turtle Window
When using the Turtle module, a window opens, displaying a turtle (represented by an arrow or a
custom shape). This turtle can move around based on commands.

(b) Turtle Movement Commands


The turtle moves across the screen using movement commands:

• t.forward(distance) :Moves the turtle forward.


• t.backward(distance) :Moves the turtle backward.
• t.right(angle) :Rotates the turtle clockwise.
• t.left(angle) :Rotates the turtle counterclockwise.
t.goto(x, y) :Moves the turtle to specific coordinates.

(c) Drawing & Pen Control


• t.pendown() :Puts the pen down to draw while moving.
• t.penup() :Lifts the pen, so movement doesn't draw.
• t.pensize(size) :Sets the pen thickness.
• t.color(color) :Changes the pen color.
t.begin_fill() and t.end_fill() :Fills a shape with color.

(d) Screen Management


• t.speed(value) :Controls drawing speed.
• t.hideturtle() :Hides the turtle from the screen.
• t.showturtle() :Displays the turtle.
• t.clear() :Clears all drawings on the screen.
• t.reset() :Clears the screen and resets the turtle.

2.4 Drawing shapes with Turtle

TURTLE BASIC

Task: In this lesson, we will create a basic square using Turtle programming.

A square has four equal sides and 90-degree angles:

educobot.com 11
This code uses Python's Turtle module to draw a square. Here's how it works step by step:

1. import turtle :Brings in the Turtle module.


2. turtle.pencolor('black') :Sets the pen color to black.
3. turtle.shape('arrow') :Changes the turtle's shape to an arrow.
4. turtle.forward(100) :Moves the turtle 100 pixels forward.
5. turtle.right(90) :Turns the turtle 90 degrees to the right.
6. The same move forward & turn right (90 degrees) repeats three more times, completing a square.
This code essentially tells the turtle to move in a loop of forward and right turns, forming a four-sided shape (square).

TURTLE BASIC

Task: In this lesson, we will create a basic circle using Turtle programming.

A circle is drawn using the t.circle(radius) function: (t stands for turtle)

This Python Turtle code draws a red circle with a radius of 45 pixels. Here's how it works:

1. import turtle :Brings in the Turtle module.


2. turtle.shape('turtle') :Sets the turtle's shape to look like a turtle.
3. turtle.pencolor('red') :Sets the pen color to red.
4. turtle.circle(45) :Draws a circle with a radius of 45 pixels.

This code simply makes the turtle draw a red circle on the screen.

educobot.com 12
TURTLE BASIC

Task: In this lesson, we will learn how to move the arrow in forward direction according to the pixel value.

This Python Turtle code moves an arrow forward by 100 pixels. Here's how it works:

1. import turtle :Brings in the Turtle module.


2. turtle.pencolor('black') :Sets the drawing color to black.
3. turtle.shape('arrow') :Changes the turtle's shape to an arrow.
4. turtle.forward(100) :Moves the arrow 100 pixels forward in a straight line.

The arrow starts at its default position and moves straight ahead by 100 pixels.

2.5 Loops in Turtle Programming


Loops help in repeating tasks to create patterns and designs efficiently.

TURTLE WHILE

Task: In this lesson, we will learn how to create a circle pattern without actually creating a circle

educobot.com 13
This Python Turtle program creates a circular pattern using repeated forward and backward
movements with rotations. Here's how it works:

Code Breakdown:
1. import turtle :Imports the Turtle module.
2. turtle.pencolor('orange') :Sets the drawing color to orange.
3. i = 0 :Initializes a counter variable i.
4. while i < 32: :Runs the loop 32 times.
• turtle.forward(50) :Moves the turtle 50 pixels forward.
• turtle.right(90) :Rotates the turtle 90 degrees to the right.
• turtle.backward(50) :Moves the turtle 50 pixels backward.
• turtle.left(20) :Rotates the turtle 20 degrees to the left.
• i += 1 :Increments i to ensure the loop runs 32 times.

Pattern Explanation:
• The forward and backward movement creates short lines.
• The left rotation (20 degrees) after each iteration makes the lines spread out in a circular
pattern.
• Repeating this 32 times (32 × 20° = 640°) creates a starburst or sun-like shape.

FOR– 44

Task: In this lesson, we will learn how to draw a square using for loop

This Python Turtle program is designed to draw a square using a for loop.

Code Breakdown:
1. import turtle :Imports the Turtle module.
2. turtle.pencolor('black') :Sets the drawing color to black.
3. for i in range(4): :Loops 4 times to draw the four sides of the square.
• turtle.forward(100) :Moves the turtle 100 pixels forward.
• turtle.right(90) :Turns the turtle 90 degrees to the right.

educobot.com 14
Pattern Explanation:
• The turtle moves forward by 100 pixels and then turns 90 degrees to the right.
• Repeating this 4 times completes the four sides of a square.
• The for loop ensures that the code is concise and efficient.
This is a great beginner-friendly Turtle graphics example for learning loops and basic shapes!

FOR– 52

Task: In this lesson, The Turtle module will draw overlapping circles, forming a circular or spirograph-like
pattern.

· import turtle – This imports the Turtle module, which helps in drawing.

· ts = turtle.Screen() – Creates a screen for drawing.

· ts.bgcolor('white') – Sets the background color to white.

· for i in range(10): – Runs a loop 10 times to create a pattern.

· turtle.circle(5) – Draws a small circle.

· turtle.circle(-5) – Draws another circle in the opposite direction.

· turtle.left(0) – Normally, this command changes the direction of the turtle, but here, left(0)
does nothing.

FOR– 54

Task: In this lesson, we will learn how to draw a square using for loop making it more colorful and creative.

educobot.com 15
This Python Turtle program is designed to draw a square with multiple colors by changing the
pen color for each side.

Code Breakdown:
1. import turtle :Imports the Turtle module.
2. wn = turtle.Screen() :Creates a screen window.
3. wn.bgcolor('pink') :Sets the background color to pink.
4. t = turtle.Turtle() :Creates a turtle object.
5. t.penup() & t.goto(100, 0) & t.pendown() :Moves the turtle to position (100,0) without drawing
and then places the pen down.
6. for c in ['red', 'green', 'yellow', 'blue']: :Iterates through a list of colors.
• t.color(c) :Changes the pen color for each side.
• t.forward(75) :Moves the turtle 75 pixels forward.
• t.left(90) :Turns the turtle 90 degrees left.

Pattern Explanation:
• The loop ensures that each side of the square is drawn in a different color.
• The turtle moves 75 pixels and turns 90 degrees at each iteration.
• This results in a colorful square on a pink background.

QUIZ TIME
Q1. Which command is used to move the turtle forward by a specified distance?
turtle.forward(distance)
turtle.move(distance)
turtle.step(distance)

Q2. What does the turtle.right(90) command do?

Moves the turtle 90 pixels forward

Rotates the turtle 90 degrees counterclockwise


Rotates the turtle 90 degrees clockwise

educobot.com 16
Q3. Which command is used to move the turtle forward by a specified distance?
turtle.up()

turtle.stop()
turtle.penup()

Q4.What will happen if you use a negative value in turtle.forward(-100)?


The turtle moves forward

The turtle moves backward


The turtle rotates 180 degrees

The turtle stops moving

SHORT ANSWER QUESTIONS


Q1. What is the purpose of the turtle.pendown() command?
Q2. Explain the difference between turtle.forward() and turtle.backward().
Q3. Explain the difference between turtle.forward() and turtle.backward().

INTRODUCTION TO DATA SCIENCE

Data science is about uncovering hidden stories within data. Imagine you have a giant box of
puzzle pieces. Data science gives you the tools to sort through those pieces, find the patterns,
and put the puzzle together to see the big picture. We use computers to help us do this because
often, the "box of puzzle pieces" is enormous!

3.1 Why is Data Science Important?

Data science helps us answer questions and make better decisions. For example:

• A store can use data science to figure out which products are most popular and how to
best stock their shelves.
• Doctors can use data science to identify patterns in patient records and develop more
effective treatments.
• Scientists can use data science to analyze climate data and understand how the Earth's
climate is changing.

educobot.com 17
3.2 What We'll Do in Data Science:

This year, we'll learn the basic steps involved in a data science project:

1. Asking Questions: Data science starts with asking interesting and important questions. What do
we want to learn? What problems are we trying to solve?
2. Gathering Data: Sometimes data is already collected for us. Other times, we might need to find
it ourselves. Think of it like getting all the puzzle pieces out of the box. Data can come from many
sources, like surveys, experiments, or online databases.
3. Cleaning and Organizing Data: Data can be messy! We need to clean it up, remove errors, and
organize it so it's easy to work with. This is like sorting the puzzle pieces by color or shape.
4. Exploring and Analyzing Data: We'll use tools and techniques to explore the data and look for
patterns, trends, and relationships. This is like trying different puzzle pieces together to see what fits.
We might use charts, graphs, and calculations to help us. This is where our data science tools come
in!
5. Visualizing Data: Creating charts and graphs helps us understand the data better and communi-
cate our findings to others. This is like seeing the picture start to emerge as you put the puzzle to-
gether.
6. Drawing Conclusions: Finally, we'll use what we've learned to draw conclusions and answer the
questions we started with. This is like seeing the complete puzzle and understanding the story it
tells.
3.3 Data Science Tools: NumPy, Pandas, and Matplotlib

In data science, we use special tools to help us work with data. Three important tools are NumPy,
Pandas, and Matplotlib.

• NumPy: NumPy is like a powerful calculator for numbers. It's really good at doing math quickly,
especially with large sets of numbers. We use NumPy for calculations like finding averages, sums,
or other statistical measures.
• Pandas: Pandas helps us organize data into rows and columns, like a spreadsheet. It makes it
easy to clean, manage, and analyze data. We use Pandas to structure our data so we can easily ex-
plore it and find patterns.
• Matplotlib: Matplotlib is our go-to tool for creating visualizations. We use it to make charts,
graphs, and other visual representations of our data, which helps us understand the data better
and communicate our findings effectively. Think of it as the tool we use to bring our data to life vis-
ually.

Learning Through Projects

The best way to learn data science is by doing! We'll work on projects that will take us through
the data science process, from gathering and cleaning data to visualizing it and drawing conclu-
sions. These projects will help you understand how data science is used in the real world and
give you hands-on experience with the tools of the trade. Here are some examples:

educobot.com 18
• Analyzing Student Survey Data: We could collect data from
student surveys and use data science techniques to analyze things
like favorite subjects, after-school activities, or study habits. We
might use Pandas to organize the survey responses and NumPy to
calculate statistics.

• Exploring Weather Data: We could use publicly available


weather data to explore trends in temperature, rainfall, or other
weather patterns. We might use Pandas to clean and organize
the weather data and NumPy to analyze temperature changes
over time.

• Investigating Movie Ratings: We could analyze movie


rating data to see which genres are most popular or if
there's a relationship between a movie's budget and its rat-
ing. We might use Pandas to create tables of movie data
and NumPy to calculate connections between budget and
rating.

Which Car Brands Are Most Popular? (Complete Guided Journey)


Introduction
Hi everyone! Today, we're going to be data detectives! We'll use data about cars to answer a
question: "Which car brands are the most popular?" Think about the cars you see on the road. Are
there certain brands you see more often? We can use data to find out which brands are truly the
most popular!
Phase 1: Asking Questions

Data science starts with asking questions. Our question is: "Which car brands are the most popular?"
We'll look at data about car sales to figure this out.
Phase 2: Gathering Data

To answer our question, we need data! I've got a file here called car_sales.csv that has information
about car sales. It has the car brand, the number of cars sold, and the car type (like Sedan, SUV, or
Hatchback). We'll use this data to find out which brands are popular.

Phase 3: Cleaning and Organizing Data


Sometimes, data can be a little messy. We need to clean it up. Here's how we'll do it using Python
and Pandas:
import pandas as pd # This line imports the Pandas library, which is a tool for
working with data. We give it the nickname "pd" so we can use it easily.

df = pd.read_csv("car_sales.csv") # This line reads the data from the


"car_sales.csv" file and puts it into a "DataFrame" called "df." A DataFrame is
like a table with rows and columns.

print("First few rows of the data:") # This line prints a message to the screen.
print(df.head()) # This line shows the first few rows of the DataFrame, so we can
get a quick look at the data.

educobot.com 19
print("\nData types and info:") # This prints a message.
print(df.info()) # This line shows us information about the DataFrame, like what
type of data is in each column (text, numbers, etc.) and if there are any missing
values.
print("\nMissing values:") # This prints a message.
print(df.isnull().sum()) # This line counts how many missing values are in each
column. Missing values are when we don't have information for a particular entry.

df.dropna(inplace=True) # This line removes any rows that have missing values. The
`inplace=True` part means the changes are made directly to the `df` DataFrame.

df['Cars Sold'] = pd.to_numeric(df['Cars Sold'], errors='coerce') # The 'Cars


Sold' column should have numbers. This line makes sure it does. If there are any
entries that aren't numbers, it will convert them to NaN (Not a Number).

print("\nData after cleaning:") # This prints a message.


print(df.info()) # We print the info again to check that the data is cleaned.

THE OUTPUT FOR THIS STEP - after you run the code

After running the code in Phase 3, students will see output similar to this (the exact order of
columns might be slightly different):
First few rows of the data:
Brand Cars Sold Car Type
0 Maruti Suzuki 150000 Hatchback
1 Hyundai 120000 Hatchback
2 Tata Motors 80000 Hatchback
3 Mahindra 60000 SUV
4 Kia 90000 SUV
First few rows of the data:
Brand Cars Sold Car Type
0 Maruti Suzuki 150000 Hatchback
1 Hyundai 120000 Hatchback
2 Tata Motors 80000 Hatchback
3 Mahindra 60000 SUV
4 Kia 90000 SUV
Missing values:
Brand 0
Cars Sold 0
Car Type 0
dtype: int64

Data after cleaning:


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 20 entries, 0 to 19
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Brand 20 non-null object
1 Cars Sold 20 non-null int64
2 Car Type 20 non-null object
dtypes: int64(1), object(2)
memory usage: 608.0+ bytes

This shows the first few rows, the data types (object for text, int64 for integers), and confirms that
there are no missing values after the dropna() command.

educobot.com 20
Phase 4: Exploring and Analyzing Data
Let's see what the data tells us!
brand_sales = df.groupby('Brand')['Cars Sold'].sum() # This line groups the data
by car brand and then calculates the total number of cars sold for each
brand. The result is stored in a new variable called `brand_sales`.

print("\nTotal cars sold by brand:") # Print a message.


print(brand_sales) # This line prints the total cars sold for each brand.

sorted_sales = brand_sales.sort_values(ascending=False) # This line sorts the


brands by the number of cars sold, from most to least. `ascending=False` means we
want the biggest numbers at the top.

print("\nTotal cars sold by brand (sorted):") # Print a message.


print(sorted_sales) # This line prints the sorted sales data.
most_popular_brand = sorted_sales.index[0] # This line finds the brand with the
most sales (which is at the top of the sorted list) and stores it in the variable
`most_popular_brand`.

print(f"\nThe most popular brand is: {most_popular_brand}") # This line prints a


message telling us which brand is most popular.

THE OUTPUT FOR THIS STEP - after you run the code
Total cars sold by brand:
Brand
Audi 8000
BMW 10000
Ford 40000
Honda 70000
Hyundai 120000
Jaguar 3000
Jeep 2000
Kia 90000
Land Rover 2000
MG 15000
Mahindra 60000
Maruti Suzuki 150000
Mercedes-Benz 12000
Nissan 10000
Porsche 1000
Renault 20000
Skoda 5000
Tata Motors 80000
Toyota 50000
Volkswagen 30000
Name: Cars Sold, dtype: int64
Total cars sold by brand (sorted):
Brand
Maruti Suzuki 150000
Hyundai 120000
Tata Motors 80000
Honda 70000
Mahindra 60000
Toyota 50000
Ford 40000
Volkswagen 30000
Renault 20000
MG 15000

educobot.com 21
Mercedes-Benz 12000
BMW 10000
Nissan 10000
Kia 90000
Audi 8000
Skoda 5000
Jaguar 3000
Jeep 2000
Land Rover 2000
Porsche 1000
Name: Cars Sold, dtype: int64

The most popular brand is: Maruti Suzuki

This shows the total cars sold for each brand, then the brands sorted by sales, and finally, the most
popular brand.

Phase 5: Visualizing Data

Let's make a chart!


import matplotlib.pyplot as plt # This line imports the Matplotlib library, which is u
for creating charts. We give it the nickname "plt."

sorted_sales.plot(kind='bar') # This line creates a bar chart of the sorted sales data
Each bar represents a car brand, and the height of the bar shows how many cars were sol

plt.title("Total Cars Sold by Brand") # This line adds a title to the chart.
plt.xlabel("Brand") # This line labels the x-axis (the bottom of the chart) with "Bran
plt.ylabel("Cars Sold") # This line labels the y-axis (the side of the chart) with "Ca
Sold."

plt.show() # This line shows the chart.

THE OUTPUT FOR THIS STEP - after you run the code

Phase 6: Drawing Conclusions

Look at the chart! Which brand is most popular? (The one with the tallest bar!) Now, write a
sentence or two explaining what you found. For example: "Maruti Suzuki is the most popular
car brand because they sold the most cars."

educobot.com 22
To create the data file:

1. Open a spreadsheet program like Microsoft Excel or Google Sheets.

2. Copy the data below, starting with "Brand,Cars Sold,Car Type".


3. Select cell A1 in your spreadsheet.
4. Paste the copied data. The spreadsheet program should automatically recognize the
commas and put each value in a separate cell. This is the crucial step. If it doesn't separate
into cells correctly, you might need to use the "Text to Columns" feature in your spreadsheet
program and choose "Comma" as the delimiter.
5. Save the file as a .csv (Comma Separated Values) file. In Excel or Google Sheets, choose
"Save As" and select CSV as the file type.

Brand,Cars Sold,Car Type

Maruti Suzuki,150000,Hatchback

Hyundai,120000,Hatchback

Tata Motors,80000,Hatchback

Mahindra,60000,SUV

Kia,90000,SUV

Honda,70000,Sedan

Toyota,50000,SUV

Ford,40000,SUV

Volkswagen,30000,Sedan

Renault,20000,Hatchback

MG,15000,SUV

Nissan,10000,Sedan

Skoda,5000,Sedan

Jeep,2000,SUV

BMW,10000,Sedan

Audi,8000,Sedan

Mercedes-Benz,12000,Sedan

Jaguar,3000,Sedan

Land Rover,2000,SUV

Porsche,1000,Sports Car

Challenge: Spot the Duplicate!

Hi everyone! You've done a great job loading and cleaning our car sales data! Now, let's talk
about something sneaky that can mess up our analysis: duplicate data.

educobot.com 23
Here's what I want you to do:

1. Instructions: "Open the car_sales.csv file in a text editor. Copy the first row of the car_sales.csv file
(Maruti Suzuki) and paste it at the very end of the file. Now you have a duplicate row. Save the file."
2. Explanation: "Run the Python code again. Does the total number of cars sold look correct? Is it
higher than it should be? Why might having duplicate data be a problem?" (Guide them to under-
stand that duplicates inflate the sales numbers, giving a wrong impression of popularity and poten-
tially skewing other calculations).
3. The Fix: "Add the following lines of code after you read the CSV file, and before you do any calcu-
lations (like grouping by brand):
df.drop_duplicates(inplace=True)
print("\nData after removing duplicates:")
print(df.info()) #Print the info again to check the change in the number of entries

Run the code again. Does the total number of cars sold look better now? How many rows are there
now? This shows how drop_duplicates() helps us clean the data."

Key Points for this focused challenge:

• Clear Instructions: The instructions are concise and specific, telling them exactly what to do.
• Targeted Explanation: The explanation focuses on the specific problem of duplicate data and
its impact on the analysis.
• Direct Solution: The code snippet is provided, so students can directly see how to fix the issue.
• Reinforced Learning: After the challenge, discuss what they learned about duplicate data and
why it's important to remove them. Ask them: "What would happen if we didn't remove the dupli-
cates? How would it affect our conclusions about which car brand is most popular?

By concentrating on this single, important concept, you'll give your students a solid under-
standing of how duplicate data can affect their analysis and how to use drop_duplicates() to
clean their data effectively. This focused approach is particularly helpful for introducing data
cleaning concepts.

Challenge 2: Exploring Car Types and Visualizing the Data – Let's Dig Deeper!

Hi everyone! Great job completing the first challenge and cleaning up our car sales data! Now that
our data is nice and tidy, let's see what else we can discover!
We've learned about which brands are most popular. But what about the types of cars? Are people
buying more Hatchbacks, SUVs, or Sedans? Let's find out!
Here's what I want you to do:

1. Group and Analyze by Car Type:


• Can you use what you already know about groupby() and sum() to group the data by 'Car Type'
and find the total number of cars sold for each type? Think about how you grouped by 'Brand' be-
fore – it's very similar!

• Once you've calculated the total sales for each car type, print the results to the screen so you
can see them.

educobot.com 24
2. Visualize Car Type Sales:
• Now, let's make a bar chart to see these results in a more visual way. Remember how we used
plot(kind='bar') before? You can use that same code, but make sure you're using the data you just
calculated (the sales by car type).

• Don't forget to add a title to your chart so everyone knows what it's about! And it's always good
to label the x and y axes so it's clear what the chart is showing. Use plt.title(), plt.xlabel(), and
plt.ylabel() for this

Need a little help? No problem! Here are some hints:

• To group by 'Car Type' and calculate the sum, use the same groupby() and sum() functions you
used before. Just change the column you're grouping by from 'Brand' to 'Car Type'.
• Creating the bar chart is easy! You can use the same plot(kind='bar') code. Just make sure you're
using the data you calculated for car type sales.

• Labeling your chart is super important so people can understand it. Remember plt.title(),
plt.xlabel(), and plt.ylabel().
Still stuck? Here's the code to help you:
import pandas as pd
import matplotlib.pyplot as plt

# ... (Your previous code to load and clean the data) ...

car_type_sales = df.groupby('Car Type')['Cars Sold'].sum()


print("\nTotal cars sold by car type:")
print(car_type_sales)

car_type_sales.plot(kind='bar')
plt.title("Total Cars Sold by Car Type")
plt.xlabel("Car Type")
plt.ylabel("Cars Sold")
plt.show()

Once you've run the code, take a good look at the output and the chart. Which car type is the
most popular? Does anything surprise you? Think about what else you could learn from this data!
Maybe you could even combine what you learned about car types with what you learned about
brands! The possibilities are endless! Let me know what you discover!

By the end of this year, you'll have a good understanding of the data science
process and be able to use tools like NumPy and Pandas to work with real-
world data. You'll be able to tell stories with data and discover insights that
would be impossible to see otherwise!

A graphical representation in data science helps visualize data patterns, trends, and relationships
effectively. Common types include line charts for trends, bar charts for comparisons, and scatter
plots for correlations. These visualizations simplify complex data, making it easier to analyze and
derive insights.

educobot.com 25
REVISION OF BASICS

Activity: In this revision activity, students will review the fundamental concepts of using a
breadboard to build circuits. They will practice connecting various components, such as LEDs,
resistors, and switches, to the breadboard, reinforcing their understanding of how to create circuits
without soldering. The focus will be on reviewing how to make proper connections, the function of
each part of the breadboard, and the importance of organizing components for effective circuit
design.

1 2

Learning Outcome: Students will refresh their knowledge of breadboarding and circuit-building
basics. They will improve their skills in connecting components correctly and gain hands-on expe-
rience in designing and testing simple circuits. This revision will reinforce their understanding of
circuit connections and component placement, laying the foundation for more advanced electron-
ics projects.

ACTIVE AND PASSIVE COMPONENTS

Activity: In this theoretical activity, students will learn about the difference between active and
passive electronic components. They will explore the characteristics, functions, and examples of
each type of component. Active components, like transistors and diodes, require an external power
source and can amplify or control electrical signals. Passive components, such as resistors,
capacitors, and inductors, do not require power and can only store or dissipate energy.

educobot.com 26
Learning Outcome: Students will understand the distinction between active and passive components and their roles
in electronic circuits. They will learn about the functionality of common components and how they contribute to circuit
behavior. This foundational knowledge will help them design and analyze circuits more effectively in future projects.

educobot.com 27
BREADBOARD CIRCUIT –BUILDING
AND GATE

Activity: In this activity, students will learn how to build an AND gate circuit on a
breadboard using basic electronic components like transistors, resistors, and LEDs.
The focus will be on understanding the logic behind the AND gate, where the output
is "high" (ON) only when both inputs are "high" (ON). Students will wire the compo-
nents and test the circuit to see how the logic gate functions, reinforcing the concept
of binary logic and its real-world applications in digital electronics.

What is an AND Gate?


An AND gate is a fundamental logic gate that produces an output only when all its
inputs are true (or high).
How Does an AND Gate Work with an LED?
Imagine you have a setup on a breadboard where an LED behaves like an AND gate:
• Regular LED Setup: When you connect the LED to 5V through a resistor, the LED
lights up. When you disconnect it, the LED goes dark.
• AND Gate LED Setup: The LED will light up only when both input connections are
made to 5V simultaneously.
Simple Example
Let's use an LED on a breadboard to demonstrate the AND gate behavior.
• Inputs: You have two points on the breadboard where you can connect to 5V.
• Output: An LED with a resistor is directly connected to the output point.

The LED will light up only if both input points (connected to 5V) are active at the same
time.
Understanding the Behavior
To see how an AND gate works using an LED:
• Connect one wire to 5V (Input A) on the breadboard.
• Connect another wire to 5V (Input B) on the breadboard.
• Connect the other end of the LED (cathode) to GND.
• Connect the anode of the LED to a point where both wires (Input A and Input B)
are connected to 5V.

educobot.com 28
This demonstrates the AND gate's behavior where the output (LED) is ON only when
both inputs are ON (connected to 5V).

Learning Outcome: Students will understand how an AND gate works and how to
build a simple logic gate circuit on a breadboard. They will gain hands-on experience
with digital logic circuits and learn the fundamentals of binary operations, which are
foundational to digital electronics and computer systems

BREADBOARD CIRCUIT - OR GATE/NOT GATE

Activity: In this activity, students will learn how to build both an OR and a NOT gate
circuit on a breadboard using basic electronic components such as transistors, resis-
tors, and LEDs. For the OR gate, the output will be "high" (ON) when any one or both
of the inputs are "high." For the NOT gate, the output will be the inverse of the input—
if the input is "high," the output will be "low," and vice versa. Students will wire the
components, test the circuits, and observe the behavior of both gates, reinforcing
concepts of binary logic and digital circuits.

What is an OR Gate?
An OR gate is another fundamental logic gate in electronics. It produces an output
when at least one of its inputs is true (or high).
How Does an OR Gate Work with an LED?
Imagine you have a setup on a breadboard where an LED behaves like an OR gate:
• Regular LED Setup: When you connect the LED to 5V through a resistor, the LED
lights up. When you disconnect it, the LED goes dark.

educobot.com 29
Simple Example
Let's use an LED on a breadboard to demonstrate the OR gate behavior.
Inputs: You have two points on the breadboard where you can connect to
5V.
Output: An LED with a resistor is directly connected to the output point.
The LED will light up if at least one of the input points (connected to 5V) is
active.
Truth Table

Input A Input B LED Output


0V 0V OFF
0V 5V ON
5V 0V ON
5V 5V ON

This table shows that the LED turns ON (lights up) if Input A is 5V OR Input
B is 5V, or both.
Building an OR Gate Circuit with an LED
You can build a simple OR gate circuit using an LED and resistors on a
breadboard.
Components Needed:
1 LED
1 resistor (220Ω or similar)
Breadboard
Connecting wires
5V power supply
Steps:
Connect the LED:

educobot.com 30
Insert the LED into the breadboard. Connect its cathode (shorter leg) to a
ground rail on the breadboard.
Connect the Resistor:
Connect one end of the resistor to the anode (longer leg) of the LED.
Setup Inputs:
Identify two points on the breadboard where you can connect 5V for Input A
and Input B.
Connect the Outputs:
Connect the other end of the resistor (opposite to the LED) to the point where
you'll observe the LED output.
Operating the Circuit:
Connect 5V to either Input A or Input B:
The LED will light up because the OR gate condition (either Input A or Input B
is 5V) is met.
Connect 5V to both Input A and Input B:
The LED will still light up because the OR gate considers any input being high
enough to turn on the LED.
Summary
An OR gate produces an output when at least one of its inputs is true. It's like
having multiple choices where picking any one leads to action!
I hope this helps you understand the concept of an OR gate using an LED on
a breadboard. If you have any more questions or want to explore other logic
gates or electronics topics, feel free to ask!

educobot.com 31
NOT GATE
What is a NOT Gate?
A NOT gate is a basic building block in electronics and computers. Its job is to flip or
invert a signal.
How Does a NOT Gate Work?
Imagine you have a special LED circuit on a breadboard that works like a NOT gate:
Regular LED Circuit: When you connect it to 5V, the LED lights up. When you connect
it to GND, the LED goes dark.
NOT Gate LED Circuit: When you connect it to 5V, the LED goes dark. When you
connect it to GND, the LED lights up.
Simple Example
Let's play a game with a NOT gate and an LED on a breadboard.
Input: You connect either 5V or GND to the circuit.

Output: The LED will do the opposite of what the input is.
If you connect 5V, the LED is OFF.
If you connect GND, the LED is ON.
So, the NOT gate makes sure the LED shows the opposite of what the input is!
Truth Table
A truth table helps us see what happens with different inputs. Here's the truth table
for a NOT gate:

Input (Voltage) Output (LED)


0V ON
5V OFF

Learning Outcome: Students will understand the working principles of OR and NOT
gates and how to build and test them on a breadboard. They will gain practical experi-
ence with logic circuits and learn how basic digital logic operations are implemented
in electronics, laying the foundation for more complex digital systems.

educobot.com 32
INTRODUCTION TO IOT

Introduction to IoT:

• Definition and examples of IoT (e.g., smart homes, wearable devices, connected cars).
• How IoT devices communicate through the internet.
• Key components of an IoT system: Sensors, Actuators, Microcontrollers, and Cloud platforms.

Key Concepts:

• Sensors: Devices that collect data (e.g., temperature, humidity, motion).


• Actuators: Devices that take action based on sensor data (e.g., motors, lights, buzzers).
• Microcontroller: A small computer that processes information and controls devices (e.g., ESP32, Arduino).
• Connectivity: Communication between devices via Wi-Fi, Bluetooth, or other protocols.
• Cloud and Data Processing: Sending data to the cloud for analysis and control (e.g., using platforms like Thing-
Speak, Blynk).

IoT System Architecture:

• Sensing: Collecting real-world data through sensors.


• Processing: Using microcontrollers to analyze and process data.
• Action: Triggering actions based on the data, such as turning on a light or activating a motor.
• Communication: Sending data to other devices or cloud platforms for further action or monitoring.

Hands-On Activities:

• Basic IoT Circuit: Connecting sensors (e.g., temperature, light, motion) to a microcontroller (e.g., ESP32, Arduino)
and displaying data on a screen.
• Remote Control via App: Creating a system where students control devices (LEDs, motors) from a mobile app
using IoT platforms.
• Data Logging and Monitoring: Using sensors to collect data and display it on a cloud platform for monitoring in
real-time.
• Automation Projects: Building smart systems like automated lighting, temperature control, or security systems
that use sensors and IoT communication to act based on data.

Learning Goals:

• Understand the core components of an IoT system.


• Learn how to build IoT projects using microcontrollers and sensors.
• Develop basic programming skills for IoT applications.
• Gain experience in integrating physical devices with the internet for smart automation.

Safety and Best Practices:

• Importance of understanding wiring and connections in IoT devices.


• Ensuring safe handling of electronics and power supplies.
• Best practices for secure IoT systems to prevent hacking or misuse.

educobot.com 33
EXPLORING IOT DASHBOARD ON INNOVATOR

Activity: In this activity, students will be introduced to the IoT Dashboard on the Innovator platform. The IoT dash-
board provides a user-friendly interface for monitoring and controlling IoT devices remotely. Students will learn how
to navigate the dashboard, view real-time data from sensors, and control connected devices (like LEDs, motors, and
sensors) from the dashboard interface. By the end of this session, students will be comfortable using the Innovator
platform to interact with their IoT projects, view sensor readings, and send control signals to their devices.

The IoT dashboard provides an overview of


projects, sensors, AI models, IoT variables,
and recent activities for efficient monitoring
and management.

SpongeBOT acts as an instant AI


assistant within the eduCOBOT
platform, providing on-the-spot
answers to coding, robotics, or IoT
-related queries. It eliminates the
need to wait for responses or
switch tabs to search, offering
real-time guidance by leveraging
its built-in knowledge and
context-specific understanding of
the user's projects and needs.

educobot.com 34
Build your own projects using the Innovator tools, and all the projects you create will
be saved and organized in the "My Projects" section for easy access and
management.

The Curriculum section provides access to various categorized lessons (e.g., IoT, AI, robotics)
where you can explore detailed instructions to code and design projects like IoT-based devices.
Simply navigate through the categories, select the desired lesson or grade, and open it to
understand the coding logic and design implementation for creating and monitoring your own
projects.

educobot.com 35
To create a project, enter the name and
description, then select the required development
environments (e.g., Robotics, IoT, AI) using the
checkboxes or "Select All." Click Create Project to
proceed with your chosen setup.

Drag and drop Widgets (switches, inputs, charts) to


design the monitor, then configure properties and
link them to your IoT devices via APIs. Save the
setup and test for proper remote control
functionality.

Learning Outcome: Students will understand how to use the IoT dashboard on Innovator to monitor, control, and man-
age IoT devices. They will learn how to visualize sensor data and trigger actions, gaining practical skills in creating user-
friendly interfaces for their IoT projects. This activity also emphasizes the importance of dashboard-based interaction for
remote monitoring and control in IoT systems.

educobot.com 36
IOT BASED LED LIGHT CONTROL

Activity: In this activity, students will learn how to control an LED light remotely using the Innovator platform and an IoT
dashboard. By connecting an LED to a microcontroller (e.g., ESP32) and integrating it with the dashboard, students will
be able to switch the LED on and off from any location via the internet. Students will program the microcontroller on
Innovator to send and receive signals, allowing them to interact with the LED light in real-time. This activity helps stu-
dents understand the fundamentals of remote control systems in IoT.

This circuit connects an LED to the eduCOBOT shield via the D2 pin. The LED can be programmed to turn on or
off based on the project's logic. This circuit can also be utilized in IoT projects for remote monitoring and control
of the LED's state.

This code connects the ESP32 to the eduCOBOT IoT platform and allows remote control of an LED. It checks the
cloud variable LED Status:

• If LED Status is '1', the LED on pin 2 turns ON.


• If not, the LED stays OFF.
This demonstrates how to control hardware using IoT.

educobot.com 37
Select the widget that you would want to use for designing your monitor in this case we are
using Switch to toggle between on and off. Click on the edit icon to select the Variable name
which will store the data.

In the IoT project, a switch on the monitor


design will allow users to remotely toggle
the LED's state (on or off) via a user-
friendly interface. This switch
communicates with the device through the
cloud, enabling real-time control of the
LED from any location.

Learning Outcome: Students will gain hands-on experience in building and programming an IoT system that allows
remote control of an LED light. They will learn how to use a dashboard to send commands and control devices via the
internet, understanding the basics of IoT connectivity, control, and data exchange.

IOT WEATHER STATION WITH DHT11

Activity: In this activity, students will create an IoT Weather Station using the DHT11 temperature and humidity sen-
sor, connected to a microcontroller mounted on the eduCOBOT shield. The students will program the microcontrol-
ler using the Innovator platform to collect real-time temperature and humidity data from the DHT11 sensor. This data
will be displayed on the IoT Dashboard, allowing students to monitor environmental conditions remotely. The activity
introduces students to the concept of collecting and visualizing real-world data through IoT.

educobot.com 38
The DHT11 sensor is connected to an ESP32 shield:

• OUT (Signal) pin: D15 (or any other GPIO pin).


• VCC: 3.3V or 5V.
• GND: GND.
The D15 pin reads temperature and humidity data, and the selected GPIO pin must match the code configuration.

In this setup, the OUT (signal) pin of the DHT11 sensor is connected to the D15 (GPIO15) pin on
the ESP32. This pin reads the sensor's temperature and humidity data, which is then
processed in the code for IoT transmission.

educobot.com 39
This dashboard uses widgets to display real-time data from the DHT11 sensor. Numeric values
for temperature and humidity are shown via label widgets, while gauge widgets provide a
visual representation for easier interpretation.

Learning Outcome: Students will learn how to interface the DHT11 sensor with a microcontroller and program it to col-
lect and transmit temperature and humidity data. They will gain practical experience in creating an IoT-based weather
station and understand how sensors work in conjunction with microcontrollers to provide real-time data that can be
monitored remotely on an IoT dashboard. This activity reinforces concepts of data collection, programming, and remote
monitoring in IoT systems.

IOT DISTANCE MANAGEMENT


WITH ULTRASONIC SENSOR

Activity: In this activity, students will build an IoT Distance Sensor system using an Ultrasonic Sensor, connected to a
microcontroller mounted on the eduCOBOT shield. The students will program the microcontroller on the Innovator
platform to measure the distance between the sensor and an object in its path. The distance data will be displayed on
the IoT Dashboard in real-time, allowing students to monitor and track distances remotely. This activity introduces stu-
dents to the concept of distance measurement using ultrasonic sensors in an IoT system.

educobot.com 40
Here’s the pin configuration for connecting the ultrasonic sensor to the ESP32 as per your setup:

VCC : 5V (ESP32 Shield 5V Pin)

GND : GND (ESP32 Shield Ground Pin)

Trig : D4 (GPIO4)

Echo : D5 (GPIO5)

This setup allows the Trig pin to send signals and the Echo pin to receive reflected signals.

This code uses an ultrasonic sensor (HCSR04) to measure distance by sending a signal from the
trigger pin and receiving it back on the echo pin. The sensor's trigger pin (GPIO 4) sends the
signal, and the echo pin (GPIO 5) receives the reflected signal to calculate the distance. The
measured distance is then sent to an IoT platform for display.

educobot.com 41
Add a Label widget to the Innovator dashboard and bind it to a variable that receives the
distance data from the ultrasonic sensor. The label will automatically update to display the
detected distance in real-time.

Learning Outcome: Students will learn how to interface an ultrasonic sensor with a microcontroller
and program it to measure distance. They will understand how ultrasonic sensors work and how to
use them in IoT applications to capture and transmit real-time data. The activity will also help stu-
dents understand how to use an IoT dashboard for remote monitoring of sensor data and gain ex-
perience with IoT-based distance measurement systems.

SMART GARBAGE MONITORING WITH IOT

Activity: In this project, students will assemble a Smart Garbage Bin from MDF parts. The system will use an Ultrasonic
Sensor to measure the fill level of the garbage bin, connected to a microcontroller mounted on the eduCOBOT shield.
Students will program the microcontroller using the Innovator platform to monitor the fill level of the bin and trigger an
action, such as turning on a light or activating a buzzer, when the bin is full. The data will be displayed on the IoT Dash-
board, allowing for remote monitoring of the bin's status.

MATERIALS REQUIRED:

X1 X1

X1 X1

educobot.com 42
2

X1 X1

X1 X3

X1

X1

Insert the ultrasonic sensor in the hole provided on the lid of the bin directly without
nuts and bolts.

educobot.com 43
5

X2

UNDERSTANDING THE CIRCUIT

Ultrasonic Sensor Pin Configuration with eduCOBOT Shield:


1. GND: Connect the GND pin of the ultrasonic sensor to the GND port on the eduCOBOT
shield.
2. VCC: Connect the VCC pin of the sensor to the VCC port on the eduCOBOT shield (5V
supply).
3. Trig: Connect the Trig pin of the sensor to D4 on the eduCOBOT shield for sending
trigger signals.
4. Echo: Connect the Echo pin of the sensor to D5 on the eduCOBOT shield to receive
reflected signals.
The buzzer is inbuilt in the eduCOBOT shield and can be programmed to provide sound
alerts based on sensor readings.

UNDERSTANDING THE CODE AND MONITOR

educobot.com 44
This code creates a Smart Bin system using an ultrasonic sensor, a buzzer, and IoT integration. Here's how it
works:

1. The ultrasonic sensor (connected to pins D4 and D5) measures the distance inside the bin.
2. If the distance is less than 10 cm (indicating the bin is full), the buzzer (on pin 27) buzzes, and the IoT
monitor displays "The bin is full".
3. If the distance is 10 cm or more (indicating the bin is empty), the buzzer stays off, and the IoT monitor
displays "The bin is empty".
4. The eduCOBOT IoT platform is used to send real-time messages about the bin's status, which are visible
on the IoT monitor.

The IoT Monitor’s label widget displays real-time messages like "The bin is full" or "The bin
is empty". Using the iot.sendData() function, the ESP32 sends these status updates to the
IoT platform via the secretKey and APIKey. The label updates automatically, allowing
students to monitor the bin's status remotely over the internet.

educobot.com 45
Learning Outcome: Students will learn how to design and build a Smart Garbage Monitoring System using an ultrasonic
sensor to detect the fill level of a garbage bin. They will gain experience in IoT integration, programming microcontrollers,
and using sensors to collect data in real-time. This project introduces the concept of smart city solutions by using IoT to
monitor waste management and provides students with a practical understanding of how to automate everyday systems.

IOT SMART DOORBELL WITH ACCESS CONTROL

Activity: In this project, students will build a Smart Door Bell system using a house model and a switch PCB. The sys-
tem will be connected to a microcontroller mounted on the eduCOBOT shield, and controlled via the IoT Monitor
Dashboard. When the button on the doorbell is pressed, the IoT Monitor Dashboard will display a notification indicating
a visitor at the door. The learner can then use a toggle button on the dashboard to either allow or deny access by
changing the state of an LED light on the system (green for allow, red for deny). This project introduces students to how
IoT can be used to remotely control access to a door and provides real-time feedback through the IoT dashboard.

MATERIALS REQUIRED:

STEP 1

X1 X1

X2

educobot.com 46
STEP 2

X1 X5

X2

X2 X1

STEP 3

X2

STEP 4

X2 X2

educobot.com 47
STEP 5

X2

Insert the RGB PCB in the given slot as


shown in the figure.

Front side

STEP 7

X1

educobot.com 48
UNDERSTANDING THE CIRCUIT

1. Touch Sensor:
• VCC is connected to the VCC port on the eduCOBOT shield.
• GND is connected to the GND port on the eduCOBOT shield.
• Signal pin is connected to the D15 port for input detection.

• RGB LED:
• VCC is connected to the VCC port on the shield.
• GND is connected to the GND port.
• Red, Green, and Blue pins are connected to D13, D14, and D12 ports respectively for controlling individual
colors.

• Servo Motor:
• VCC is connected to the VCC port on the shield.
• GND is connected to the GND port.
• Signal pin is connected to the D23 port for movement control..

UNDERSTANDING THE CODE AND MONITOR

educobot.com 49
This code creates a Smart House Doorbell System using a touch sensor, LEDs, a servo motor, and the
eduCOBOT IoT Monitor. When someone touches the sensor, the buzzer buzzes, and the IoT Monitor displays
"You Have a Visitor". If the user selects Allow, the servo motor opens the door (moves to 90°) and lights up the
green LED. If the user selects Disallow, the yellow LED turns on, and the door remains closed. After processing,
the system resets, and the monitor updates to "No Visitor At The Moment".
NOTE: This is not the complete code .

The Switch Widget is used to allow or disallow visitors, and the Label Widget displays the
notification status (e.g., "No Visitor At The Moment"). The Allow (green checkmark) and
Disallow (red cross) sections provide toggles for access control, making it an efficient IoT-
based visitor management system.

educobot.com 50
INTRODUCTION TO ARTIFICIAL INTELLIGENCE
AND MACHINE LEARNING

Have you ever wondered how your phone unlocks just by looking at you? Or how a website
seems to know exactly what you want to buy? These amazing feats of technology are often
powered by two exciting fields: Artificial Intelligence (AI) and Machine Learning (ML). In this
introduction, we'll explore what these terms mean and how they're changing the world
around us.

What is Artificial Intelligence (AI)?

Imagine a computer that can play chess as well as a


grandmaster, or a program that can translate languages
instantly. That's the power of Artificial Intelligence! AI is
all about creating machines that can perform tasks that
typically require human intelligence. This includes
things like:

• Thinking and Problem Solving: AI systems can


analyze information, make decisions, and solve
complex problems, much like we do.
• Learning and Adapting: AI can learn from experience and improve its performance
over time, just as humans learn from their mistakes.
• Understanding Language: AI can understand spoken and written language, allowing
us to communicate with computers more naturally.
• Seeing and Recognizing: AI can process images and videos, recognizing objects, faces,
and even emotions.

Think of AI as a broad goal: creating intelligent machines. It's like a big umbrella that covers
many different techniques and approaches.

What is Machine Learning (ML)?

Machine Learning is one way to achieve Artificial Intelligence. It's a technique that allows computers
to learn from data without being explicitly programmed for every single task. Instead of writing a set
of rules, we feed the computer lots of examples, and it figures out the patterns itself.

Think of it like teaching a puppy a new trick. You don't tell it exactly how to do it; you show it what
you want it to do, and you reward it when it gets it right. The puppy learns to associate the action
with the reward. Machine Learning works in a similar way:

• Data is the Key: We give the computer lots of data, which acts like the examples we show
the puppy.
• Finding Patterns: The computer analyzes the data to find patterns and relationships, just
like the puppy learns to connect the action with the reward.
• Making Predictions: Once the computer has learned the patterns, it can use them to make
predictions or decisions on new, unseen data.

educobot.com 51
For example, imagine you want to teach a computer
to identify different types of fruit. You could give it
lots of pictures of apples, bananas, and oranges, and
label each picture with the correct fruit name. The
computer would analyze the pictures, looking for
features like color, shape, and size, and learn to dis-
tinguish between the different fruits. Then, if you
showed it a new picture of a fruit, it could use what it
learned to predict what type of fruit it is.

Machine Learning is a powerful tool because it allows computers to learn and adapt without
needing to be programmed for every single possibility. It's a key ingredient in many of the AI
applications we use every day.

AI, ML, and DL: What's the Difference?

Imagine you're trying to teach a robot to play soccer. That's like Artificial Intelligence (AI) –
making robots smart enough to do things humans do. AI is the big goal: creating intelligent ma-
chines.

Now, you could try to tell the robot exactly what to do in every situation: "If the ball is here, kick it
that way. If another player is there, move to the left," and so on. But that would take forever!

Instead, you could show the robot lots of examples of people playing soccer: "Here's a video of
someone kicking the ball. Here's a video of someone scoring a goal." The robot watches all
these videos and starts to figure out the rules of soccer by itself. That's Machine Learning (ML)
– teaching computers by giving them examples. ML is one way to reach our AI goal.

Deep Learning (DL) is like having a super-smart robot soccer coach. This coach can watch
thousands of soccer videos and learn even the trickiest moves and strategies. Deep Learning uses
special networks (like a robot brain) to understand all that information. It's really good at learning
from lots and lots of examples. DL is a super-smart way of doing ML.

Think of it like this:

• AI: Building a smart robot.


• ML: Teaching the robot by showing it examples.
• DL: Having a super-smart robot coach.

educobot.com 52
Now that we understand the basic ideas behind AI and Machine Learn-
ing, let's explore a fun and relatable example: predicting video game
genres! Imagine you're building a video game recommendation system.
You want the computer to suggest games to players based on their
preferences. How can we use Machine Learning to do this?

A Fun Example: Predicting Video Game Genres

Let's say we're building a video game recommendation system. We want the computer to guess
what genre of game someone might like (Action, Adventure, Puzzle, etc.). We can use Machine
Learning for this!

Imagine we have some information about a video game:

• Average User Rating (out of 10): How much players liked the game.
• Number of Players: Is it single-player, multiplayer, or massively multiplayer?
• Platform: Is it on PC, PlayStation, Xbox, Nintendo Switch, etc.?
• Year Released: When the game came out.
These pieces of information are called features. They're the clues our ML model will use to make its
prediction. What we want the model to predict – the game's genre – is called the target.

How Machine Learning Works (Simplified)

1. Training: We start by giving the ML model a bunch of examples. We show it games with their
features and their genres. The model looks for patterns. Maybe games with high ratings and lots of
players tend to be Action games. This is called training the model.
2. Predicting: Once the model is trained, we give it new games – games it hasn't seen before. We
give it the features (rating, players, platform, year), but we don't tell it the genre. The model uses
what it learned during training to predict the genre.

A Very Simple Example (Manual Prediction)

Let's say we have these games:

• Game A: Rating 8, Multiplayer, PC, 2022 (Genre: Action)


• Game B: Rating 9, Single Player, Console, 2021 (Genre: Adventure)
• Game C: Rating 7, Multiplayer, PC, 2023 (Genre: Action)

educobot.com 53
Now, we have a new game: Rating 7, Multiplayer, Console, 2023. What genre do you think it is?

(Learner Answer Space):

Probably Action, right? You used the patterns you saw in the first three games to make your
prediction. That's exactly what a machine learning model does, but it does it automatically and
with much more data!
From Manual Prediction to Machine Learning – Let's See the Code!

Machine learning models automate the process you just did manually. They learn the patterns in
the data so they can make predictions automatically. We use special computer code (Python!) to
do this. We'll use two helpful tools: pandas (for working with data) and scikit-learn (for machine
learning). Here's the code we'll use, and here's how to get the data:

1. Creating the video_games.csv File:

1. Copy the Data: Copy the text below, starting with "Rating,Players,Platform,Year,Genre". This is
your video game data.
Rating,Players,Platform,Year,Genre
8,Multiplayer,PC,2022,Action
9,Single Player,Console,2021,Adventure
7,Multiplayer,PC,2023,Action
6,Single Player,Console,2020,Adventure
9,Multiplayer,PC,2022,Action
5,Single Player,Mobile,2019,Puzzle
8,Multiplayer,PC,2023,Action
7,Single Player,Console,2021,Adventure
9,Multiplayer,PC,2022,Action
6,Single Player,Mobile,2020,Puzzle
7,Multiplayer,Console,2023,Action
8,Single Player,PC,2021,Adventure
9,Multiplayer,PC,2022,Action
6,Single Player,Mobile,2020,Puzzle
7,Multiplayer,Console,2023,Action
8,Single Player,PC,2021,Adventure
9,Multiplayer,PC,2022,Action
6,Single Player,Mobile,2020,Puzzle
7,Multiplayer,Console,2023,Action
8,Single Player,PC,2021,Adventure

2. Open Notepad (or a similar text editor): Open Notepad (on Windows) or TextEdit (on Mac) or
any plain text editor.

3. Paste the Data: Paste the copied data into the Notepad window.

educobot.com 54
4. Save the File: This is the crucial step. Go to "File" -> "Save As...".

• File name: Type video_games.csv (make sure you include the .csv part).
• Save as type: Choose "All Files" (or ensure it saves as plain text, not Rich Text Format or
anything else).
2. The Python Code:
from sklearn.linear_model import LogisticRegression # Imports the Logistic Regres-
sion model from scikit-learn (our ML tool).
import pandas as pd

games_data = [
{"Rating": 8, "Players": "Multiplayer", "Platform": "PC", "Year": 2022,
"Genre": "Action"},
{"Rating": 9, "Players": "Single Player", "Platform": "Console", "Year": 2021,
"Genre": "Adventure"},
{"Rating": 7, "Players": "Multiplayer", "Platform": "PC", "Year": 2023,
"Genre": "Action"},
{"Rating": 6, "Players": "Single Player", "Platform": "Console", "Year": 2020,
"Genre": "Adventure"},
{"Rating": 9, "Players": "Multiplayer", "Platform": "PC", "Year": 2022,
"Genre": "Action"},
{"Rating": 5, "Players": "Single Player", "Platform": "Mobile", "Year": 2019,
"Genre": "Puzzle"},
{"Rating": 8, "Players": "Multiplayer", "Platform": "PC", "Year": 2023,
"Genre": "Action"},
{"Rating": 7, "Players": "Single Player", "Platform": "Console", "Year": 2021,
"Genre": "Adventure"},
{"Rating": 9, "Players": "Multiplayer", "Platform": "PC", "Year": 2022,
"Genre": "Action"},
{"Rating": 6, "Players": "Single Player", "Platform": "Mobile", "Year": 2020,
"Genre": "Puzzle"},
{"Rating": 7, "Players": "Multiplayer", "Platform": "Console", "Year": 2023,
"Genre": "Action"},
{"Rating": 8, "Players": "Single Player", "Platform": "PC", "Year": 2021,
"Genre": "Adventure"},
{"Rating": 9, "Players": "Multiplayer", "Platform": "PC", "Year": 2022,
"Genre": "Action"},
{"Rating": 6, "Players": "Single Player", "Platform": "Mobile", "Year": 2020,
"Genre": "Puzzle"},
{"Rating": 7, "Players": "Multiplayer", "Platform": "Console", "Year": 2023,
"Genre": "Action"},
{"Rating": 8, "Players": "Single Player", "Platform": "PC", "Year": 2021,
"Genre": "Adventure"},
{"Rating": 9, "Players": "Multiplayer", "Platform": "PC", "Year": 2022,
"Genre": "Action"},
{"Rating": 6, "Players": "Single Player", "Platform": "Mobile", "Year": 2020,
"Genre": "Puzzle"},
{"Rating": 7, "Players": "Multiplayer", "Platform": "Console", "Year": 2023,
"Genre": "Action"},
{"Rating": 8, "Players": "Single Player", "Platform": "PC", "Year": 2021,
"Genre": "Adventure"},
]

df = pd.DataFrame(games_data)

Code continuation on next page

educobot.com 55
df = pd.get_dummies(df, columns=['Players', 'Platform']) # Converts text data in
'Players' and 'Platform' to numbers using one-hot encoding.

X = df.drop('Genre', axis=1) # Creates 'X' containing the features (everything


*except* 'Genre').
y = df['Genre'] # Creates 'y' containing the target (just the 'Genre').

model = LogisticRegression(max_iter=1000) # Creates our machine learning model


(Logistic Regression).
model.fit(X, y) # Trains the model by showing it the features (X) and the correct
genres (y).

new_games = pd.DataFrame({'Rating': [7, 9], # Creates a DataFrame for two *new*


games that we want to predict the genre for.
'Year': [2024, 2022],
'Players_Multiplayer': [1, 0], # 1 means True
(Multiplayer), 0 means False
'Players_Single Player': [0, 1], # 1 means True (Single
Player), 0 means False
'Platform_Console': [1, 0], # 1 means True (Console), 0
means False
'Platform_Mobile': [0, 0], # 1 means True (Mobile), 0
means False
'Platform_PC': [0, 1]}) # 1 means True (PC), 0 means
False

predictions = model.predict(new_games) # Makes the predictions on the new game


data.
print("Predictions:", predictions) # Prints the model's predicted genres for the
new games.

Running the Code and Seeing the Results:

1. Save the Code: Save the Python code above in a file named game_predictor.py (or any name
you like, but make sure it ends in .py). Save this file in the same folder where you saved vid-
eo_games.csv.
2. Open a Terminal or Command Prompt: On Windows, search for "cmd" or "Command Prompt".
On Mac, open "Terminal".
3. Navigate to the Folder: Use the cd command to navigate to the folder where you saved the
files. For example, if you saved them in a folder called "AI_Project" on your Desktop, you might

Challenge: Become a Video Game Genre Expert!

Now that we've learned the basics of machine learning and how to predict video game genres, it's
your turn to become a genre expert!

Your Mission:

You will expand our video game database and then use our machine learning model to make pre-
dictions on the new data. This will test your data handling skills, your ability to modify code, and
your analytical thinking.

Here's what you need to do:

1. Expand the Data:


• Open the video_games.csv file in a text editor (like Notepad or TextEdit).
• Add at least five new video games to the file. Be creative! Think about games you like or games
you've heard about.

educobot.com 56
• For each new game, include the following information, separated by commas, just like the
existing data:
• Rating (a number out of 10)
• Players (Multiplayer or Single Player)
• Platform (PC, Console, Mobile, or any new platforms you want to add, like "Nintendo
Switch")
• Year (the year the game was released)
• Genre (the actual genre of the game – this is what the model will learn from)
• Important: If you add any new platforms that aren't already in the data (like "Nintendo
Switch"), you'll need to make a small change to the Python code in the next step.
1. Modify the Code:
• Open the game_predictor.py file (the Python code we've been using).
• If you added any new platforms in the data (like "Nintendo Switch"), find the line that
says:Pythondf = pd.get_dummies(df, columns=['Players', 'Platform'])You might need to add the
new Platform names. For example, if you added "Nintendo Switch," the line might be-
come:Pythondf = pd.get_dummies(df, columns=['Players', 'Platform', 'Nintendo Switch']) # If it is a
new column.
• Save the game_predictor.py file.
2. Run the Code and Analyze the Results:
• Run the Python code. You should see the model's predictions for the genres of your new
games.
• Now, the important part: Look at the predictions. Do they make sense? Why or why not?
Think about the features of the games you added and how they might have influenced the
model's predictions.

• Write a short paragraph (2-3 sentences) explaining your observations. Did the model do a
good job? Were there any surprises? What did you learn about how machine learning models
make predictions?

Example:

Let's say you add these games to video_games.csv:

9,Multiplayer,Nintendo Switch,2023,Action
7,Single Player,Xbox,2022,Adventure
6,Multiplayer,Mobile,2024,Puzzle
8,Multiplayer,PC,2023,Strategy
10,Single Player,PlayStation,2024,RPG

And the model predicts:

['Action' 'Adventure' 'Puzzle' 'Strategy' 'RPG']


You might then write: "The model's predictions seem reasonable. It correctly predicted the
genres for most of the games. I noticed that games with high ratings and lots of players were
often predicted as 'Action' or 'Strategy,' which makes sense."

That's it! Have fun becoming a video game genre expert! Don't be afraid to experiment and
see what happens. The more you work with the data and the code, the more you'll learn
about machine learning!

educobot.com 57
INTRODUCTION TO MODEL TRAINING

Step-by-Step Guide to Model Training and Saving


The form in the image is used for creating
and saving a machine learning model using
Teachable Machine. It includes several key
sections:
1. **Instructions**:
- Click on Train Model.
- A new pop-up window will open. Add or
capture your data and train the model.
- Click on Export Model to get a shareable
link for the model.
- Once you have the model link, close the
window.
- Enter the model name and description.
- Paste the Teachable Machine URL.
- Verify the class names.
- Click on Create. Your model will be suc-
cessfully created.
2. **Form Fields**:
- **Enter Model Name**: A text field.
- **Enter Model Description**: A text field.
- **Enter Teachable URL**: A text field.
3. **Class List from this model**:
- Three checkboxes labeled "Tarun", "Other", and "Environment".
4. **Buttons**:
- A blue button labeled "Train The Model".
- A blue button labeled "Save Model".

The image provides a step-by-step guide for creating and saving a machine learning model,
which can be particularly useful for users working with AI and machine learning technologies.
It helps users follow a clear process to train and deploy their models efficiently.

educobot.com 58
Class Sections
In this section, users can add image samples for different classes that the model needs to recog-
nize. Each class, such as "Tarun," "Other," and "Environment," has its own dedicated area where
users can either use a webcam to capture images or upload images from their devices. This al-
lows the model to learn and distinguish between the different classes. Additionally, there is an
option at the bottom to "Add a class," enabling users to create more classes as needed for their
specific use case.

Training Section
This section contains the essential controls for training the model. The "Train Model" button initi-
ates the training process using the images provided in the class sections. There is also an
"Advanced" dropdown that offers additional training options, allowing users to customize the
training process to better suit their needs. This section is crucial for developing a robust model
that accurately identifies the specified classes.

Preview Section
Before utilizing the model, users must train it. This section provides a message stating, "You must
train a model on the left before you can preview it here." Once the model is trained, users can
preview its performance in this section. Additionally, the "Export Model" button allows users to
save and share the trained model, making it accessible for deployment in various applications.

This layout demonstrates how Teachable Machine streamlines the process of creating, training,
and deploying image classification models, providing an intuitive interface that caters to both be-
ginners and experienced users in machine learning.

educobot.com 59
The export section of the Teachable Machine interface provides users with the tools to export their trained machine
learning models efficiently. This section includes options for exporting the model using various formats such as Ten-
sorFlow.js, TensorFlow, or TensorFlow Lite. Users can choose to upload the model to obtain a shareable link, down-
load the model, or update an existing cloud model. This flexibility is particularly useful for developers who want to
integrate their models into web applications or other platforms quickly and effectively.

Additionally, this section offers code snippets that demonstrate how to use the exported model in different program-
ming environments. Users can find sample code for both JavaScript and p5.js, with each snippet designed to help in-
tegrate the Teachable Machine model into a web application. The provided code includes essential elements for ini-
tializing the model, starting it, and displaying relevant information such as webcam feeds and labels. This organized
and user-friendly export section streamlines the process of deploying machine learning models, making it accessible
for a wide range of practical applications.

SMART HOUSE WITH AI

MATERIALS REQUIRED:

STEP 1

X1 X2
X1

STEP 2

X1 X2

X2 X1 X5

educobot.com 60
STEP 3

X2

STEP 4

X2 X2

STEP 5

X2

Insert the RGB PCB in the given slot as


shown in the figure.

Front side
educobot.com 61
Hardware Required:
1.eduCOBOT Shield
2. RGB PCB
3. Servo Motor

Pin Configuration:
esp32 RGB esp32 Servo Motor
VCC VCC GND GND

D13 R VCC VCC

D12 G D23 Dout

D14 B

Circuitry:

This circuit features an eduCOBOT shield connected to an RGB LED and a servo motor. The RGB
LED has four wires: VCC, GND, Red (R), Green (G), and Blue (B). VCC is connected to the 3.3V pin on
the eduCOBOT shield, and GND is connected to a GND pin. The Red, Green, and Blue wires are
each connected to separate GPIO pins on the shield, allowing individual control of the LED's color
channels. The servo motor has three wires: VCC, GND, and Signal. VCC is connected to the 5V pin
on the eduCOBOT shield, GND is connected to a GND pin, and the Signal wire is connected to an-
other GPIO pin. This setup allows the eduCOBOT shield to control the RGB LED's colors and oper-
ate the servo motor.

The environment depicted in the image is a virtual circuit designing tool. This online tool enables
users to design and test electronic circuits without physical components. It's ideal for prototyping
and learning about electronics, as it provides a user-friendly interface to experiment with various
configurations and components. Using such a designing environment, users can gain valuable in-
sights into their circuit designs, troubleshoot issues, and refine their projects before implementing
them in real-world scenarios.

educobot.com 62
UNDERSTANDING CODE AND CODING ENVIRONMENT

Block-Based Code
The block-based coding interface allows users to drag and drop blocks to form logical structures
easily. In this scenario, you would use:

1. WiFi Connection Block: To connect the eduCOBOT shield to the WiFi network by entering
the SSID and password.
2. Servo Motor Control Blocks: To control the servo motor’s position by setting it to angles
such as 0°, 90°, or 180°, based on specific conditions.
3. RGB LED Control Blocks: To manage the RGB LED, setting various colors by adjusting the
intensities of the Red, Green, and Blue channels.
4. Loop and Conditional Blocks: To create loops and conditions that control the program’s
flow, such as moving the servo motor and changing the RGB LED’s color based on sensor input
or specific triggers.

By using the MicroPython code editor, you can easily switch between block-based and syntax-
based coding to suit your preferences and project requirements. This setup helps in prototyping
and refining your smart house project before implementing it in a real-world scenario.

The Smart House project with AI focuses on enhancing home security and automation using
face recognition technology. The key components of this project include a camera for face de-
tection, an AI model trained to recognize authorized faces, an eduCOBOT shield, an RGB LED,
and a servo motor. Here's a step-by-step explanation of the project:

Face Recognition and Model Training

1. Data Collection: Collect images of authorized faces and label them accordingly. These
images will be used to train the face recognition model.
2. Model Training: Use a face recognition algorithm (e.g., OpenCV, TensorFlow, or other
machine learning frameworks) to train the model on the collected images. The model learns
to identify and classify faces based on the given data.
3. Real-Time Detection: Once the model is trained, it can be deployed to detect faces in
real-time using a camera. The camera captures the image and processes it through the
trained model to identify if the face belongs to an authorized person.

educobot.com 63
Door Control and LED Indication

1. WiFi Connectivity: Connect the eduCOBOT shield to a WiFi network to enable remote
control and monitoring of the system.
2. Face Detection and Action:
• Authorized Face: If the detected face matches the trained model's authorized class, the
eduCOBOT shield sends a signal to the servo motor to open the door. Simultaneously, the
RGB LED turns green to indicate successful access.
• Unauthorized Face: If the detected face does not match any authorized class, the door
remains closed. The RGB LED turns red to signal unauthorized access.
3. Servo Motor Control: The servo motor, connected to the eduCOBOT shield, controls the
door mechanism. It moves to a specific angle to open or close the door based on the face
recognition result.
4. RGB LED Indication: The RGB LED provides a visual indication of the access status. Green
indicates successful access, while red indicates unauthorized access.

UNDERSTANDING AI LOGIC AND ENVIRONMENT:

The image presents an AI logic environment where logic is written to compare class names
with the real-time output of an AI model, performing actions on hardware via WiFi functions.

Logic Environment:
1. Condition Blocks:
• Condition 1: If the result of getFinalPrediction() equals Tarun, the system verifies the
class name and signals the hardware to perform an action (e.g., opening the door via the
servo motor).
• Condition 2: If the result equals Other, the system signals the hardware as verified.
• Condition 3: If the result equals Environment, the system signals the hardware as not
verified.
2. Action Blocks:
• Opening the Door: When the class name matches Tarun, the servo motor is activated
to open the door.
• LED Indication: The RGB LED is set to green when access is granted (class matches
Tarun), and red if access is denied (other classes).

educobot.com 64
Real-Time Output:
• The model’s output section displays a label (e.g., "Other") and a bar graph with probability per-
centages for classes Tarun, Other, and Environment. The bar graph shows the highest probability
for the "Other" class, indicating the current prediction.

This environment exemplifies how AI predictions can integrate with hardware actions, enhancing
automated home security systems by responding based on real-time data analysis.

SUMMARY:
By integrating face recognition with home automation, the Smart House project provides en-
hanced security and convenience. AI technology is employed to recognize authorized individuals
through face detection. When a recognized face is detected, the system automatically opens the
door using a servo motor, while an RGB LED turns green to indicate successful access.

On the other hand, if an unauthorized face is detected, the door remains closed, and the RGB LED
turns red to indicate access denial. This real-time response ensures that only authorized individu-
als can enter the house, providing a seamless and automated solution for home security.

7 SEGMENT DISPLAY WITH AI

MATERIALS NEEDED

X1 X1 X1 X2

X1 X1 X2

STEP 1

educobot.com 65
STEP 2

STEP 3

X1 X2

STEP 4

Hardware Required:
1.eduCOBOT Shield
2. Seven Segment

Pin Configuration:
esp32 7 Segment esp32 7 Segment
VCC VCC D26 D

D21 A D32 E

D22 B D33 F

D25 c D5 G

educobot.com 66
Circuitry:

The image showcases a circuit design environment where an eduCOBOT shield is connected to a
seven-segment display. The eduCOBOT shield is mounted on a breadboard-like base, providing
various connection points for different components. The seven-segment display is connected to
the shield via a set of wires, each corresponding to a segment of the display. This setup highlights
how the eduCOBOT shield can interface with display components to visualize numerical data, con-
trolled by the underlying microcontroller.

The environment depicted in the image is a digital circuit designing tool. This tool allows users to
design and test electronic circuits virtually before physically building them. It provides a user-
friendly interface for placing and connecting components, making it a valuable resource for educa-
tion, prototyping, and learning about microcontroller-based projects. The right side of the image
shows a selection of various input and output sensors, which can be incorporated into the design,
further enhancing the learning experience.

UNDERSTANDING CODE AND CODING ENVIRONMENT


The image presents an AI logic environment divided into two sections: a visual programming in-
terface on the left and a Python code editor on the right. The visual programming interface al-
lows users to create logic by comparing class names with the real-time output of an AI model
and performing actions on hardware using WiFi functions. For example, the interface includes
blocks for initializing WiFi, starting a server, and handling server requests to control a seven-
segment display. Specific conditions like "display-1," "display-2," "display-3," "display-4," and
"display-5" are used to set values for the display, which controls the output on the seven-
segment display.

The Python code editor on the right side translates the visual logic into Python code. The code
snippet shown is not complete but provides an overview of the process. It imports necessary li-
braries, sets up WiFi credentials, and defines a function to connect to the WiFi network. It handles
connection attempts and saves the configuration to a JSON file. The code also includes logic for
starting a server and controlling the seven-segment display based on server requests. The com-
plete code would include additional elif conditions for "display-1," "display-2," "display-3," "display-
4," and "display-5," each corresponding to displaying digits on the seven-segment display based
on the server input.

educobot.com 67
This dual-interface environment demonstrates how visual programming can be converted into tra-
ditional code, making IoT development accessible and versatile for both beginners and advanced
users. This setup allows users to write and test logic for smart devices, integrating AI predictions
and hardware actions seamlessly.

UNDERSTANDING AI LOGIC AND ENVIRONMENT:

The image shows an AI logic environment where we write logic to compare class names and real-
time outputs from a model, and then perform actions on hardware using functions called on hard-
ware with WiFi. On the left side of the image, there is a block-based programming interface with
conditional statements. Each statement checks if the function getFinalPrediction() equals a spe-
cific class name, such as "Class 1." When the condition is true, the hardware performs an action,
like setting the display to 'display-1' or 'display-5' on the seven-segment display.

On the right side of the image, there is a real-time camera feed showing a hand gesture (index fin-
ger pointing up) and a bar graph displaying the probability percentages for five different classes.
The highest probability is for "Class 1," around 55%. This environment demonstrates how AI models
can be integrated with hardware to perform specific actions based on real-time predictions, useful
for applications in automation, robotics, and smart devices. The code snippet shown is not com-
plete; it would include additional elif conditions for "display-1," "display-2," "display-3," "display-4,"
and "display-5," each corresponding to displaying digits on the seven-segment display based on
server input. This setup allows users to seamlessly integrate AI predictions and hardware actions,
enhancing the development of smart devices.

SUMMARY:
The content depicts a circuit setup in a digital circuit designing tool, featuring an eduCOBOT shield
connected to a seven-segment display. This virtual environment allows users to design and test
electronic circuits before implementing them physically.

Another part of the content showcases an AI logic environment with a block-based programming
interface on the left and a Python code editor on the right. This setup compares class names with
real-time model outputs to perform actions on hardware, like setting the seven-segment display
to different values via WiFi.

educobot.com 68
Additionally, it includes a real-time camera feed showing a hand gesture and a bar graph of
probability percentages for five classes. This environment demonstrates AI model predictions
and corresponding hardware actions. The code snippet indicates logic to match predictions and
trigger hardware responses

educobot.com 69
MRP | 71 Pages |

Mumbai: 6th Floor, 288 Shiv Sadan S V Road,

Bandra West, Mumbai, Maharashtra 400050

www.educobot.com

support@educobot.com

+91-7278517851

Published By Kritrima Prajna Innovations Pvt Ltd, Mumbai

You might also like