Workshop 1
Workshop 1
Workshop-1
Arduino UNO
Basic Structure
of Arduino UNO
• Microcontroller: Microcontroller is the main component of Arduino Uno. The
Arduino Uno board is a microcontroller based on the ATmega328.
• 14 Digital Pins: Arduino Uno Consist of 14 Digital Pins Where output Components
like: LED, LCD, Relay etc. are connected. These work for a value of HIGH or LOW.
• Analog Pins: Arduino Uno Consist of 6 Analog Pins, Analog Pins are usually used to
connect sensor like: IR Sensor , RF Sensor these all sensor have analog value that’s
why they are connected to analog pins, Most of the input components are
connected here. These pins return a value of 0-255.
• PWM – The pulse width modulation pins marked with the (~) symbol can simulate
analog output
• Reset Button: This is used to start the programme again which is once uploaded.
• Voltage Regulator:The function of the voltage regulator is to control the voltage
given to the Arduino board and stabilize the DC voltages used by the processor
and other elements.
• Crystal Oscillator:The crystal oscillator helps Arduino in dealing with time issues.
How does Arduino calculate time? The answer is, by using the crystal oscillator.
The number printed on top of the Arduino crystal is 16.000H9H. It tells us that
the frequency is 16,000,000 Hertz or 16 MHz.
• Power LED indicator:This LED should light up when you plug your Arduino into a
power source to indicate that your board is powered up correctly. If this light
does not turn on, then there is something wrong with the connection.
• Built-in LED: This LED is internally connected to I/O pin 13 of Arduino uno and
lights up when commanded on pin 13.
• Power Supply: The power supply pins are Vin, 5V, 3.3V, GND, IOREF are used to
power Input and output components. The recommended range is 7 to 12 volts to play
your board safe.
• Power Jack: Arduino board can be powered either by USB connection or with an
external power supply. This is used to power the Arduino board where we connect a
dc source from 7-12 volts.
• USB Port: This port function to programme the board or to upload the programme.
The one end of USB cable is connected to the laptop and another to this port. With
help of Arduino software and USB cable, one can upload the programme on the
board.
Arduino IDE
Arduino IDE:
● The Arduino language is C++ thus it is a
case sensitive language.
● Most of the time, people will use a small
subset of C++, which looks a lot like C.
If you are familiar with Java, then you
will find C++ easy to work with and to
recognize.
● The simplest possible Arduino sketch is
this
What are variables?
● name of the memory location. It is used to store data.Its value can be changed, and it can be reused
many times.
Integer (int) Numeric data type for numbers without fractions -707, 0, 707
Floating Point (float) Numeric data type for numbers with fractions 707.07, 0.7, 707.00
Array List with a number of elements in a specific order—typically of the same type rock (0), jazz (1), blues (2),
pop (3)
Character (char) Single letter, digit, punctuation mark, symbol, or blank space a, 1, !
String (str or text) Sequence of characters, digits, or symbols—always treated as text hello, +1-999-666-3333
Why we need function?
void checkTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
{
// Condition to check if
// area is not equal to 0
if (a == 0)
cout << "No";
else
cout << "Yes";
}
Function
The function is a block of statement
or instruction enclosed by curly
braces { } that together perform one
of the special tasks
Basic syntax of function
return_type function_name (parameter list){
//function body
return (expression)
}
return_type: Return type can be of any data type such as int, double, char, void, short etc.
argument list: Argument list contains variables names along with their data types. These arguments are
kind of inputs for the function. For example – A function which is used to add two integer variables, will
be having two integer argument.
Block of code: Set of statements, which will be executed whenever a call will be made to the function.
Example
If-else
statement
● If else Statement in C programming
language, when we need to execute a block
of statements that too when a particular
condition is met or not met that situation is
known as decision making.
● In C programming, the decision-making
process is used to specify certain orders in
which statements are executed.
Basic syntax of if-else statement
Example
int marks=75
if(marks<=40){
print(“You are fail”)
}
if(40<marks<=50){
print(“You got D grade”) Output:
}
else if(50<marks<=60){ You got A grade
print(“You got C grade”)
}
else if(60<marks<=70){
print(“You got B grade”)
}
else if(70<marks<=80){
print(“You got A grade”)
}
else {
print(“You got A+”)
Basic structure of for loop
for(initialization; test Expression; increment/decrement)
{
Body of Loop
}
initialization: this allows you to initialize the initial value for the loop control.
test expression: This is for testing the condition. If the condition satisfies enter into the for loop
body and execute the code of for loop.
increment/decrement: This is for increments or decrements of the value of the variable each
time after the execution of the for loop body.
Setting up Arduino IDE :
● Step-1: Go to https://www.arduino.cc/ or just search download Arduino IDE on google
● Step-2: Install the latest version of Arduino IDE according to your system.
● Step-3: Install the IDE by leaving everything as default.
● Step-4: Open the IDE.
● Click on verify button.
● Click on upload button.
● After the uploading is successful the terminal shows the message Done Uploading and you will
see the led on your board blinking at interval of 1 sec.
● First go to
https://www.tinkercad.com/
and create a student account.
● Now click on new button and
then select Circuit.
● A new blank project starts.
01
TinkerCAD
Project 1
Basic LED Project
What we are working on
void loop(){
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(LED_BUILTIN, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
01
TinkerCAD
Project 2
A simple traffic light circuit
What we are working on