Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

4in1 Arduino Tutorial 1

Uploaded by

mervynmada2001
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)
8 views

4in1 Arduino Tutorial 1

Uploaded by

mervynmada2001
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/ 17

BRUTE FORCE

ELECTRONICS-PROGRAMMING-ROBOTICS

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Course Overview

▪ Week 1 – Electronics
▪ Week 2 – Programming
▪ Week 3 – Arduino
▪ Week 4 – Robotics

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Tutorial 1

Introduction to Arduino

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Focus
● Introduction to Arduino
● Understanding Arduino Functions
● Arduino Data Types
● Arduino Function Libraries
● Inter Integrated Circuits (I2C)

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino - Basics
● Arduino is a prototype platform (open-source) based on an easy-to-use hardware
and software. It consists of :
✓ a circuit board, which can be programmed (referred to as a microcontroller).
✓ a ready-made software called Arduino IDE (Integrated Development
Environment), which is used to write and upload the computer code to the
physical board.
● Arduino key features are:
✓ Arduino boards are able to read analog or digital input signals.
✓ You can control your board functions by sending a set of instructions to the
microcontroller via Arduino IDE (referred to as uploading software).
✓ Arduino does not need an extra piece of hardware (called a programmer) in order
to load a new code onto the board. You can simply use a USB cable.
✓ The Arduino IDE uses a simplified version of C /C++, making it easier to learn to
program.
✓ Arduino provides a standard form factor that breaks the functions of the
microcontroller into a more accessible package.

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Board Descriptions
Power
▪ Arduino board can be powered by using the USB cable from yo
computer. All you need to do is connect the USB cable to the US
connection (1).
▪ Arduino boards can be powered directly from the AC mains power supp
by connecting it to the Barrel Jack (2).
▪ 3.3V (6): Supply 3.3 output volt
▪ 5V (7): Supply 5 output volt
▪ GND (8)(Ground): There are several GND pins on the Arduino, any
which can be used to ground your circuit.
▪ Vin (9): This pin also can be used to power the Arduino board from a
external power source, like AC mains power supply.
Tx and Rx- at the digital pins 0 and 1, to indicate the pins Arduino Reset
responsible for serial communication. Second, the TX and RX
led (13). The TX led flashes with different speed while sending▪ You can reset your Arduino board, i.e., start your program from t
the serial data. The speed of flashing depends on the baud rate beginning. You can reset the board in two ways, by using the reset butt
used by the board. RX flashes during the receiving process. (17) on the board or connect an external reset button to the Arduino p
labelled RESET (5).

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Board Descriptions
Analog Pins
▪ The Arduino Uno board has five analog input pins A0 through A5. These
pins can read the signal from an analog sensor like the humidity sensor or
temperature sensor and convert it into a digital value that can be read by
the microprocessor.
Digital I/O
▪ The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide
PWM (Pulse Width Modulation) output. These pins can be configured to
work as input digital pins to read logic values (0 or 1) or as digital output
pins to drive different modules like LEDs, relays, etc. The pins labelled
“~” can be used to generate PWM.

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Data Types
● Data types used in Arduino programming are:
➢ Void – The void keyword is used only in function declarations. It indicates that the function is expected to return no
information to the function from which it was called.
Example

➢ Boolean - A Boolean holds one of two values, true or false. Each Boolean variable occupies one byte of memory.
Example

➢ Byte -A byte stores an 8-bit unsigned number, from 0 to 255.


➢Int - Integers are the primary data-type for number storage. int stores a 16-bit (2-byte)
➢Float - Data type for floating-point number is a number that has a decimal point. Floating-point numbers are often used
to approximate the analog and continuous values because they have greater resolution than integers.

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Data Types
● Some other data types used in Arduino include:
➢ Long
➢ Short
➢ Unsigned int
➢ Char
➢ Unsigned char
➢ Double
➢ Word
➢ Sting- char array

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Function Libraries
➢ The pins on the Arduino board can be configured as either
inputs or outputs. We will explain the functioning of the pins in
those modes.

1. PinMode() Function - is used to configure a specific pin to


behave either as an input or an output. It is possible to enable
the internal pull-up resistors with the mode INPUT_PULLUP.
Additionally, the INPUT mode explicitly disables the internal
pull-ups.

● pinMode() Function Syntax

● Void setup () {
● pinMode (pin , mode);
● }
● pin − the number of the pin whose mode you wish to set
● mode − INPUT, OUTPUT, or INPUT_PULLUP.
BRUTE FORCE bruteforcehub@gmail.com +263718384192
Arduino Function Libraries
2. digitalWrite() Function - is used to write a HIGH or a LOW
value to a digital pin. If the pin has been configured as an
OUTPUT with pinMode(), its voltage will be set to the corresponding
value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable
(HIGH) or disable (LOW)
the internal pullup on the input pin.
➢ If you do not set the pinMode() to OUTPUT, and connect an
LED to a pin, when calling digitalWrite(HIGH), the LED may
appear dim.

digitalWrite() Function Syntax


Void loop() {
digitalWrite (pin ,value);
}
● pin − the number of the pin whose mode you wish to set
● value − HIGH, or LOW.
BRUTE FORCE bruteforcehub@gmail.com +263718384192
Arduino Function Libraries
3. analogRead() Function - reads the value from the
specified analog pin present on the particular Arduino board.
The ADC (Analog to Digital Converter) on the Arduino board is
a multichannel converter. It maps the input voltage and the
operating voltage between the values 0 and 1023. The
operating voltage can be 5V or 3.3V.
The values from 0 to 1023 are the integer values. It can also be
written as 0 to (2^10) -1.

analogRead() Function Syntax


analogRead(pin);

● pin − the number of the analog input pin to read from (0 to 5


on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the
Mega)

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Arduino Function Libraries
● 3. analogWrite() Function - is used to update the status
of analog pins and also used to address the PWM pins on the
board.
● The PWM pins are 8-bit pins, terming that you can set the
duty cycle somewhere between 0 -255.

analogWrite() Function Syntax


analogWrite(pin, value)

pin: the Arduino pin to write to. Allowed data types: int.
value: the duty cycle: between 0 (always off) and 255 (always
on). Allowed data types: int.

BRUTE FORCE bruteforcehub@gmail.com +263718384192


Inter Integrated Circuits
● (I2C) is a system for serial data exchange between the microcontrollers and
specialized integrated circuits of a new generation. It is used when the
distance between them is short (receiver and transmitter are usually on the
same printed board).
● I2C is created to provide simple ways for digital information to be transferred
between sensors and microcontrollers such as Arduino.
● Arduino libraries for both I2C and SPI make it easy for you to use both of
these protocols. The choice between I2C and SPI is usually determined by
the devices you want to connect. Some devices provide both standards, but
usually a device or chip supports one or the other.

● I2C has the advantage that it uses only two signal connections to Arduino-
multiple devices on the two connections is fairly easy, and you get
acknowledgment that signals have been correctly received.
● The disadvantages are that the data rate is slower than SPI and data can
only be traveling in one direction at a time, lowering the data rate even more
if two-way communication is needed.
BRUTE FORCE bruteforcehub@gmail.com +263718384192
...Inter Integrated Circuits
● The two connections for the I2C bus are called SCL and SDA.
● Following are the pins for different Arduino boards −
✓ Uno, Pro Mini A4 (SDA), A5 (SCL)
✓ Mega, Due 20 (SDA), 21 (SCL)
✓ Leonardo, Yun 2 (SDA), 3 (SCL)

● We have two modes that are used to connect two Arduino boards using I2C. These are −
✓ Master Transmitter / Slave Receiver
✓ Master Receiver / Slave Transmitter

BRUTE FORCE bruteforcehub@gmail.com +263718384192


● One device on the I2C bus is considered the master device. Its job is to coordinate the transfer of information
between the other devices (slaves) that are attached.
● There must be only one master, and in most cases the Arduino is the master, controlling the other chips attached to
it.

● I2C devices need a common ground to communicate. The Arduino Ground pin must be connected to ground on each
I2C device.
● The Arduino Wire library hides all the low-level functionality for I2C and enables simple commands to be used to
initialize and communicate with devices.

BRUTE FORCE bruteforcehub@gmail.com +263718384192


THANK YOU ARDUINO GEEKS!

IGNITING CREATIVITY - LEARN BY DOING


BRUTE FORCE bruteforcehub@gmail.com +263718384192

You might also like