Robotics Review Sheet
Robotics Review Sheet
Learning Objectives
Arduino UNO
What exactly is Arduino?
According to the Arduino website (http://www.arduino.cc/), it is an open-source
electronics prototyping platform based on flexible, easy-to-use hardware and
software. It’s intended for artists, designers, hobbyists, and anyone interested
in creating interactive objects or environments. In simple terms, the Arduino is
a tiny computer system that can be programmed with your instructions to
interact with various forms of input and output. The current Arduino board
model, the Uno, is quite small in size compared to the average human hand,
as you can see in the Figure.
Although it might not look like much to the new observer, the Arduino system
allows you to create devices that can interact with the world around you. By
using an almost unlimited range of input and output devices, sensors,
indicators, displays, motors, and more, you can program the exact interactions
required to create a functional device. For example, artists have created
installations with patterns of blinking lights that respond to the movements of
passers-by, high school students have built autonomous robots that can
detect an open flame and extinguish it, and geographers have designed
systems that
monitor temperature and humidity and transmit this data back to their offices
via text message.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
You’ll find an almost infinite number of examples with a quick search on the
Internet.2
3
Blinking LED
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Challenge:
Design a simple LED circuit using
Arduino UNO.
Testable Goal:
Arduino acts as a power source to light
up an LED.
Materials Required:
Materials Quantity
.
Arduino Uno 1
USB Cable 1
Bread Board 1
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Instruction Sheet
1. You’re going to use the Arduino in this project, but only as a source of power. When
plugged into a USB port or a 9-volt battery, the Arduino will provide 5 volts between
its 5V pin and its ground pin that you can use. 5V = 5 volts.
2. If your Arduino is connected to a battery or computer via USB, unplug it before
building the circuit!
3. Connect a red wire to the 5V pin on the Arduino and put the other end in one of the long
bus lines in your breadboard. Connect the ground on the Arduino to the adjacent bus
line with a black wire. It’s helpful to keep your wire color consistent (red for power,
black for ground) throughout your circuit.
5. Use a 220-ohm resistor to connect power to one side of the LED. On the other side of
the LED, connect the anode (long leg) to the positive rail or 5v power pin. With a wire
connect the cathode (short leg) of the LED to the ground. When you’re ready, plug the
USB cable into the Arduino. You should see the LED light up.
Challenge:
Design a simple Arduino circuit using an LED and a switch on Tinkercad.
Components List:
∙ Arduino UNO R3
∙ Resistor
∙ LED
∙ Connecting Wires
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Sketch
void setup()
{
pinMode(ledPin,OUTPUT); //Set the digital 8 port mode, OUTPUT: Output mode
}
void loop()
{
digitalWrite(ledPin,HIGH); //HIGH is set to about 5V PIN8 delay(1000); //Set
the delay time, 1000 = 1 second digitalWrite(ledPin,LOW); //LOW is set to
about 5V PIN8 delay(1000); //Set the delay time, 1000 = 1 second }
Understanding Code
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
2. To make the speed of the animation adjustable, create a variable that will serve as the amount of time between
state changes. Name the variable "animationSpeed”.
3. At the beginning of the program, set the variable to your desired time, in milliseconds.
4. Drag the new variable animationSpeed onto the wait block to set the wait time to whatever
animationSpeed is set to. Don't forget to adjust the dropdown menu from "seconds" to "milliseconds."
5. Use another output block to set the next pin 12 HIGH, then LOW, with another pause after each.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
6. Right click and select Duplicate to create a new copy of the block for as many LEDs as you have left, then
change the pin numbers to correspond to the connected LEDs. Test out your code by starting the simulator.
Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement function, the ranging
accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit.This is
a simple example of using the ultrasonic sensor (HC-SR04) in Arduino where we will turn on a led with the
variation of distance and print the distance from an object to the serial monitor.
1. Arduino Uno
3. Mini-BreadBoard
4. 1 kohm Resistor.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
5. Jumpers.
6. Blue LED.
The connection of the components is very easy it is only necessary to follow the following pictures.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
You may have already learned to read a pushbutton and PIR motion sensor with Arduino's digital
input, and we'll build on those skills in this lesson.
Ultrasonic rangefinders use sound waves to bounce off objects in front of them, much like bats using
echolocation to sense their environment. The proximity sensor sends out a signal and measures how
long it takes to return. The Arduino program receives this information and calculates the distance
between the sensor and object.
Instructions
1. Explore the sample circuit here in the workplane by starting the simulation and clicking on the proximity sensor.
This will activate a highlighted area in front of the sensor with a circle "object" inside. You may need to resize the
view if the circle is off screen.
2. Click and drag the "object" circle closer and further away, noticing the changing distance values on screen.
3. In this lesson, you'll build this simulated circuit yourself along side the sample. To optionally build the physical
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
circuit, gather up your Arduino Uno board, USB cable, solderless breadboard, three LEDs, resistors (any value
from 100-1K), ultrasonic rangefinder, and breadboard wires.
Just as you’ve learned from the introductory lessons, start by wiring up your Arduino and breadboard
with power and ground next to the example circuit, then add the the three red LEDs to the
breadboard, as shown. These will be the "bar graph" lights for visually indicating the sensor's distance
measurement.
Instructions
1. Drag an Arduino Uno and breadboard from the components panel to the workplane, next to the existing circuit.
2. Connect the 5 volt and ground pins on the Arduino to the power (+) and ground (-) rails on the breadboard with
wires. You can change the wire colors if you want to! Either use the inspector dropdown or the number keys on
your keyboard.
3. Drag three LEDs on the breadboard in row E, spaced 2 breadboard sockets apart. You can change the LED color
using the inspector that pops up when you click on each one.
4. Use a 220 Ohm resistor to connect each LED's cathode (left leg) to the ground rail (black) of the breadboard.
You can change a resistor's value by highlighting it and using the dropdown menu.
5. Connect the LED anodes (right legs) to digital pins 4, 3, and 2 on the Arduino. Stuck?
Proximity sensors come in multiple flavors. Here in Tinkercad Circuits, you can choose between a
three-pin sensor or a four-pin sensor. In general, ultrasonic rangefinders have one pin that connects to
ground, another that connects to 5 volts, a third for sending a signal, and a fourth for receiving a
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
signal. The 'send' and 'receive' pins are combined into one pin on the three-pin flavor.
Instructions
1. In the circuits editor, find the ultrasonic rangefinder in the components drawer. To find the four-pin sensor, view
"All" in the components panel (using the dropdown menu).
2. Place the sensor on the breadboard to the left of the LEDs in row E, as shown in the figure.
3. Wire up the sensor so the 5V pin connects to the 5V voltage rail, the GND pin connects to the ground rail, the
SIG or TRIG pin to Arduino pin 7, and, if using the four-pin flavor, the ECHO pin connects to Arduino pin 6.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
1. Click the "Code" button to open the code editor. The grey Notation blocks are comments for making note of
what you intend for your code to do, but this text isn't required or executed as part of the program.
2. Click on the Variables category in the code editor. Create a new variable called distanceThreshold and use a
"set" block to set it to 350 (centimeters).
4. Drag out a "set" block and adjust the dropdown to our new variable cm.
5. In the Input category, drag out a "read ultrasonic distance sensor on" block, and place it inside the set block.
6. Adjust the dropdown menus inside the input block to set the trigger pin to 7, the echo pin to "same as trigger"
and units to cm.
7. Optionally create a new variable for converting centimeters to inches with a set block and an arithmetic block
to read "set inches to (cm / 2.54)".
8. Add some serial monitoring blocks to print out the sensor distance in centimeters and inches.
9. Click the Control category and drag out an if then block, then navigate to Math and drag a comparator block
onto the if block.
10. In the Variables category, grab the cm variable and the distanceThreshold variable and drag them into the
comparator block, adjusting the dropdown so it reads "if cm > distanceThreshold then".
11. Add three digital output blocks inside the if statement to set pins 2, 3, and 4 LOW.
12. Duplicate this if statement four times and add arithmetic blocks and and/or blocks to create five total state
detection if statements. The first state is "the distance is farther than our threshold" so no LEDs light up. When
the distance is closer than or equal to the distanceThreshold and greater than distanceThreshold-100, light up
only pin 2's LED. When the temperature is between distanceThreshold-100 and distanceThreshold-250, light
up two LEDs. And so on to account for all the desired states.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
1) Arduino Uno x 1
2) Ultrasonic Sensor x 1
3) Servo Motor x 1
4) Breadboard
The servo motor will rotate to a certain angle depending on the distance detected by the ultrasonic
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
sensor. The distance detected will also be displayed on the serial monitor.
1) Connect the 5V pin of the Arduino board to the bottom row of the breadboard
2) Connect the GND pin to the top row of the breadboard.
3) Connect the VCC pin of the sensor to the positive terminal of the breadboard.
2) Connect the ground terminal of servo motor to the negative terminal of the breadboard.
1. Identify the PIR motion sensor, LED, resistor, and wires connected to the Arduino in the Tinkercad Circuits
workplane.
2. Drag an Arduino Uno and breadboard from the components panel to the workplane, next to the existing
circuit.
3. Connect breadboard power (+) and ground (-) rails to Arduino 5V and ground (GND), respectively, by
clicking to create wires.
4. Extend power and ground rails to their respective buses on the opposite edge of the breadboard by creating a
red wire between both power buses and a black wire between both ground buses.
5. Plug the LED into two different breadboard rows so that the cathode (negative, shorter leg) connects to one
leg of a resistor (anywhere from 100-1K ohms is fine).
Show hint
6.
7. Connect other resistor leg to ground.
8. Wire up the LED anode (positive, longer leg) to Arduino pin 13.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
9. Drag a PIR motion sensor from the components panel to your breadboard, so its legs plug into three different
rows.
12. Create a wire connecting the leftmost leg to Arduino analog pin A0.
2. Click on the Variables category in the code editor. Create a new variable called sensorState.
4. We’ll store the state of our PIR motion sensor to our variable sensorState. Click on the Input block
category, drag out the the “read digital pin” block, and place it into the “set” block after the word “to”.
5. Since our sensor is connected to the Arduino on Pin 2, change the dropdown of the “read digital pin” block to
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
2. Now your blocks should read “set sensorState to read digital pin 2” which stores a digital reading of the
sensor pin into our sensorState variable!
6. Click the Control category and drag out an "if then" block.
7. Configure it to evaluate whether sensorState is equal to HIGH using a Math comparator block. Drag out the
Math comparator block into your if statement to check whether our variable sensorState is equal to HIGH.
8. We want to turn our LED on if the sensor is activated - otherwise, we want our LED to be off. Under the
Output block category, find the “set built-in LED to HIGH” block. Try adding two of these blocks to our if
statement so that the LED will only be on when the sensor is activated.
This project uses the Arduino UNO to synchronize and manage a four-way traffic signal, giving a complete
solution for traffic crossings.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Components Required
Mini Breadboard
Arduino UNO
Traffic Light Module x 4
Male Header
Female Header
On/Off Switch
Battery Clip
9V Battery
Circuit Diagram
The power source in the circuit schematic is a 9-volt battery that can be turned on and off using a switch. The
configuration includes the Arduino UNO, the central component. The Arduino is linked to four traffic light
modules, each of which represents a signal pole. Each traffic light module’s circuitry has 100-ohm resistances
connected in series with the red, yellow, and green LEDs’ positive terminals. Each signal pole’s LEDs are wired
to a distinct pin on the Arduino. For example, the LEDs of pole 1 are allocated pins 2, 3, and 4, while pole 2 is
assigned pins 5, 6, and 7. Pins 8, 9, and 10 correspond to pole 3, and pins 11, 12, and 13 correspond to pole 4.
The Arduino’s ground pin is linked to the common ground pins of each of the four modules.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Code Explaination :
The code given is for an Arduino microcontroller software that controls a series of LED traffic signal lights for
four separate poles. Each pole has three LEDs, which stand for the red, yellow, and green signals, and these
LEDs are attached to designated pins on the Arduino board. Variables for each signal’s open times are
initialized by the code, along with a variable that indicates how long the yellow signal will last until turning
green. There are further variables to monitor the current mode of operation, time in milliseconds, and seconds.
The setup function sets the starting mode to 0 and initializes the timers and pin modes. The loop function,
which cycles through several modes to regulate the traffic signals, is where the core logic is implemented. The
software use timers to control the length of each state, with each mode denoting a distinct condition in the
traffic light sequence. Depending on the current mode, the yellow and open routines are called to control the
yellow and green LEDs, respectively. Open the code on Arduino IDE. Compile the code. Select the board as
Arduino UNO. Then, select the port. After this, upload the code on the Arduino UNO
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Sound sensors can be used for a variety of things, one of them could be turning lights off and on by clapping.
Today however we are going to use hook up the sound sensor to an array of LED lights which will beat with
music, clapping or knocking.
Arduino UNO
A Sound Sensor
LED
Mini Breadboard
Wires
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
This module allows you to detect when sound has exceeded a set point you select.Sound is detected via a
microphone and fed into an LM393 op amp. The sound level set point is adjusted via an on board potentiometer.
When the sound level exceeds the set point, an LED on the module is illuminated and the output is sent low.
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Connections list
Lets learn how to use temperature and humidity sensor dht 11 module with lcd display.
Parts Required :
● Arduino Uno/Mega/Nano
● 2x16 Lcd display with i2c controller
● Dht 11 module
● Jumper wire
An IR sensor is a device that measures the Infrared radiation in its surroundings and gives an electric signal as
an output. An IR sensor can measure the heat of an object as well as can detect the motion of the objects.
Parts Required :
● IR sensor
● Arduino UNO
● Jumper wires
● Breadboard
● led
● VCC - 5V
● GND- GND
● OUT PIN- PIN 7
● LED Anode - Resistor - Dig Pin 13
● LED Cathode - Gnd
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
In this project:
● You will create an AI model using image data to classify whether a person is wearing a mask, not wearing a mask and
wrongly wearing a mask.
● Open pictoblox and choose block coding.
● next from the file menu open the ML environment.
● Now create a project with appropriate names and select the image classifier.
● Select the image classifier as project type and click on the create button.
● Introduce them with the AI environment, how to create classes , in this case 3 as mask on: mask off and wrong mask
● now train the model and test the model
● after testing export the model to pictoblox block coding environment to write the following Programming:
● Create the following program in pictoblox by selecting their favorite sprite
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
Question: In what situations could you use the Mask classifier model?
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8
● Object detection has two components: object classification and object localization. In other words, to detect an
object in an image, the computer needs to know what it is and where it is.
Programming:
Lahore Grammar School
Middle Section for Girls
49-Civic Centre, Johar Town, Lahore Grade: 8