Introduction To Arduino, Pictoblox and Evive.
Introduction To Arduino, Pictoblox and Evive.
Presented By C.K.Vinodh
CEN
(Centre for Computational Engineering and Networking)
1
S.NO CONTENT Page
1 Arduino overview no3
2 Arduino mega pinout 6
3 Power 8
4 Pin maping 9
5 Ardunio mega analog pin sampling rate. 14
6 Resolution 15
7 PWM 16
8 Pictoblox 19
9 Evive 23
10 Evive IOT kit 37
11 sensors 45
12 Arduino blink 46
13 Arduino fade 50
13 Example code for library function 52
14 Evive blink 55
15 Evive Dable and pictoblox light on off 56
17 Evive pwm 65
18 Basic of Electrical and Electronics 69
2
ARDUINO
Overview
3
Getting Started
Find inspiration for your projects with the Mega 2560 board from our tutorial
platform Project Hub.
You can find in the Getting Started with Arduino MEGA2560 Rev 3 section
all the information you need to configure your board, use the Arduino
Software (IDE), and start tinkering with coding and electronics.
From the Tutorials section you can find examples from libraries and built-in
sketches as well other useful information to expand your knowledge of the
Arduino hardware and software.
Need Help?
Check the Arduino Forum for questions about the Arduino Language, or
how to make your own Projects with Arduino. Need any help with your
board please get in touch with the official Arduino User Support as
explained in our Contact Us page.
4
Tech specs
MICROCONTROLLER ATmega2560
OPERATING VOLTAGE 5V
INPUT VOLTAGE 7-12V
(RECOMMENDED)
INPUT VOLTAGE (LIMIT) 6-20V
DIGITAL I/O PINS 54 (of which 15 provide
PWM output)
ANALOG INPUT PINS 16
DC CURRENT PER I/O PIN 20 mA
DC CURRENT FOR 3.3V PIN 50 mA
FLASH MEMORY 256 KB of which 8 KB used
by bootloader
SRAM 8 KB
EEPROM 4 KB
CLOCK SPEED 16 MHz
LED_BUILTIN 13
LENGTH 101.52 mm
WIDTH 53.3 mm
WEIGHT 37 g
5
Pinout Diagram
Learn more
6
ARDUINO DOCSFor the full technical documentation, tutorials
and much more, visit Arduino Docs
FAQs
Programming
The Mega 2560 board can be programmed with the Arduino Software
(IDE). For details, see the reference and tutorials.
You can also bypass the bootloader and program the microcontroller
through the ICSP (In-Circuit Serial Programming) header using Arduino
ISP or similar; see these instructions for details.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source
code is available in theArduino repository. The ATmega16U2/8U2 is loaded
with a DFU bootloader, which can be activated by:
7
Warnings
The Mega 2560 has a resettable polyfuse that protects your computer's
USB ports from shorts and overcurrent. Although most computers provide
their own internal protection, the fuse provides an extra layer of protection.
If more than 500 mA is applied to the USB port, the fuse will automatically
break the connection until the short or overload is removed.
Power
The Mega 2560 can be powered via the USB connection or with an
external power supply. The power source is selected automatically.
Vin. The input voltage to the board when it's using an external power
source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or,
if supplying voltage via the power jack, access it through this pin.
5V. This pin outputs a regulated 5V from the regulator on the board.
The board can be supplied with power either from the DC power jack
(7 - 12V), the USB connector (5V), or the VIN pin of the board (7-
12V). Supplying voltage via the 5V or 3.3V pins bypasses the
regulator, and can damage your board. We don't advise it.
8
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum
current draw is 50 mA.
IOREF. This pin on the board provides the voltage reference with
which the microcontroller operates. A properly configured shield can
read the IOREF pin voltage and select the appropriate power source
or enable voltage translators on the outputs for working with the 5V or
3.3V.
Memory
The ATmega2560 has 256 KB of flash memory for storing code (of which 8
KB is used for the bootloader), 8 KB of SRAM and 4 KB of EEPROM
(which can be read and written with the EEPROM library).
9
In addition, some pins have specialized functions:
LED: 13. There is a built-in LED connected to digital pin 13. When the
pin is HIGH value, the LED is on, when the pin is LOW, it's off.
10
TWI: 20 (SDA) and 21 (SCL). Support TWI communication using
the Wire library. Note that these pins are not in the same location as
the TWI pins on the old Duemilanove or Diecimila Arduino boards.
The Mega 2560 has 16 analog inputs, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground
to 5 volts, though is it possible to change the upper end of their range using
the AREF pin and analogReference() function.
There are a couple of other pins on the board:
Communication
The Mega 2560 board has a number of facilities for communicating with a
computer, another board, or other microcontrollers. The ATmega2560
provides four hardware UARTs for TTL (5V) serial communication. An
ATmega16U2 (ATmega 8U2 on the revision 1 and revision 2 boards) on
the board channels one of these over USB and provides a virtual com port
to software on the computer (Windows machines will need a .inf file, but
OSX and Linux machines will recognize the board as a COM port
automatically. The Arduino Software (IDE) includes a serial monitor which
allows simple textual data to be sent to and from the board. The RX and TX
LEDs on the board will flash when data is being transmitted via the
ATmega8U2/ATmega16U2 chip and USB connection to the computer (but
not for serial communication on pins 0 and 1).
11
A SoftwareSerial library allows for serial communication on any of the
Mega 2560's digital pins.
The Mega 2560 also supports TWI and SPI communication. The Arduino
Software (IDE) includes a Wire library to simplify use of the TWI bus; see
the documentation for details. For SPI communication, use the SPI library.
The maximum length and width of the Mega 2560 PCB are 4 and 2.1
inches respectively, with the USB connector and power jack extending
beyond the former dimension. Three screw holes allow the board to be
attached to a surface or case. Note that the distance between digital pins 7
and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the
other pins.
Rather then requiring a physical press of the reset button before an upload,
the Mega 2560 is designed in a way that allows it to be reset by software
running on a connected computer. One of the hardware flow control lines
(DTR) of the ATmega8U2 is connected to the reset line of the
ATmega2560 via a 100 nanofarad capacitor. When this line is asserted
(taken low), the reset line drops long enough to reset the chip. The Arduino
Software (IDE) uses this capability to allow you to upload code by simply
pressing the upload button in the Arduino environment. This means that the
bootloader can have a shorter timeout, as the lowering of DTR can be well-
coordinated with the start of the upload.
12
This setup has other implications. When the Mega 2560 board is connected
to either a computer running Mac OS X or Linux, it resets each time a
connection is made to it from software (via USB). For the following half-
second or so, the bootloader is running on the ATMega2560. While it is
programmed to ignore malformed data (i.e. anything besides an upload of
new code), it will intercept the first few bytes of data sent to the board after
a connection is opened. If a sketch running on the board receives one-time
configuration or other data when it first starts, make sure that the software
with which it communicates waits a second after opening the connection
and before sending this data.
The Mega 2560 board contains a trace that can be cut to disable the auto-
reset. The pads on either side of the trace can be soldered together to re-
enable it. It's labeled "RESET-EN". You may also be able to disable the
auto-reset by connecting a 110 ohm resistor from 5V to the reset line;
see this forum thread for details.
13
Ardunio mega analog pin sampling rate.
For a 16 MHz Arduino the ADC clock is set to 16 MHz/128 = 125 KHz.
Each conversion in AVR takes 13 ADC clocks so 125 KHz /13 = 9615 Hz.
That is the maximum possible sampling rate, but the actual sampling rate in
your application depends on the interval between successive
conversions calls.
14
What is resolution?
0 to 2.500
2.5 to 501
5 to 7.510
7.5 to 10 11
So in this example, the 2-bit digital value can represent 4 different
numbers, and the voltage input range of 0 to 10 volts is divided into 4
pieces giving a voltage resolution of 2.5 volts per bit. A 3-bit digital value
can represent 8 (23) different numbers. A 12-bit digital value can represent
4096 (212) different numbers. A 16-bit digital value can represent 65536
(216) different numbers. It might occur to you at this point that a digital
input could be thought of as a 1-bit analog to digital converter. Low
voltages give a 0 and high voltages give a 1.
analogRead()
[Analog I/O]
Description
Reads the value from the specified analog pin. Arduino boards contain a
multichannel, 10-bit analog to digital converter. This means that it will map
input voltages between 0 and the operating voltage(5V or 3.3V) into
integer values between 0 and 1023. On an Arduino UNO, for example,
this yields a resolution between readings of: 5 volts / 1024 units or, 0.0049
volts (4.9 mV) per unit. See the table below for the usable pins, operating
voltage and maximum resolution for some Arduino boards.
15
The input range can be changed using analogReference(), while the
resolution can be changed (only for Zero, Due and MKR boards)
using analogReadResolution().
On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100
microseconds (0.0001 s) to read an analog input, so the maximum
reading rate is about 10,000 times a second.
PWM
16
Pulse Width Modulation, or PWM, is a technique for getting analog
results with digital means. Digital control is used to create a square
wave, a signal switched between on and off. This on-off pattern
can simulate voltages in between the full Vcc of the board (e.g.,5V
on Uno, 3.3 V on a MKR board) and off (0 Volts) by changing the
portion of the time the signal spends on versus the time that the
signal spends off. The duration of "on time" is called the pulse
width. To get varying analog values, you change, or modulate, that
pulse width. If you repeat this on-off pattern fast enough with an
LED for example, the result is as if the signal is a steady voltage
between 0 and Vcc controlling the brightness of the LED.
17
PWM
Once you get this example running, grab your arduino and shake it
back and forth. What you are doing here is essentially mapping
time across the space. To our eyes, the movement blurs each LED
blink into a line. As the LED fades in and out, those little lines will
grow and shrink in length. Now you are seeing the pulse width.
18
Pictoblox
Installing
https://thestempedia.com/tutorials/getting-started-pictoblox
Getting started
https://thestempedia.com/tutorials/getting-started-pictoblox
19
PictoBlox, like Scratch, has the following basic elements:
1. Sprites
2. Stage
3. Blocks
4. Script
Sprites
20
A sprite has costumes, which are one of the many appearances of the
sprite. Some sprites have multiple costumes, and you’ll use blocks to
perform actions.
Stage
The stage is the area where the sprite performs actions according to your
program. The stage has its own scripts and sounds. You can decorate the
stage using images; these images are called backdrops. You can choose
a backdrop from PictoBlox’s inbuilt library, paint one yourself, upload an
image from your computer or even click a picture.
Script
The block palette is under the Code tab. It consists of different palettes
such as Motion, Sound, and Control. Each palette has different blocks that
perform functions specified by the palette name. E.g., the blocks in the
Motion palette will control the motion of the sprite and the blocks in the
Control palette will control the working of the script depending on specific
conditions.
There are other varieties of block palettes that can be loaded from the Add
Extension button located at the left bottom.
21
Modes
22
EVIVE
Features
23
Power Module
evive has its own inbuilt Li-ion 2200mAh battery, giving it portability and
durability. It can also be powered externally by a USB wall charger, power
bank, DC wall adapter, laptops and >12V batteries. These inputs have
reverse polarity, overvoltage and overcurrent protection to protect you and
your evive in the event of any mistakes. evive also has a host of power
output ports, with a fixed 5V/3A supply, fixed 3.3V/0.8A supply and a
tunable voltage supply from 1.25 – 30V/3A.
Power Switch
Internal Battery
Power Input
5V Output
LED Indicators
24
Reverse Polarity Protection
Overcurrent Protection
Overvoltage Protection
Hardware Interaction
With two knob potentiometers, 2 tactile switches, 2 slide switches, a 5-way
navigation key and 12 capacitive touch inputs, evive makes it incredibly
easy to interact with your projects without any messy circuits.
Knob Potentiometer
25
Tactile Switches
Slide Switches
DC Motor
26
DC Motor Driver
Servo Motor
Stepper Motor
Relay
Pnuematics
Modes of Feedback
evive has multi-modal feedback, both visual and auditory. The 1.8” TFT
screen with 18-bit colour and a resolution of 160x128px displays the menu
27
which controls evive, but can be programmed according to your custom
needs. It has 1 single-colour and 2 dual-colour programmable LEDs, along
with fixed LEDs for serial communication, power indication and battery
charging status. The auditory mode consists of a 2k-10kHz piezo buzzer.
Piezo Buzzer
TFT Screen
Programmable LEDs
28
Real Time Clock
2 Channels
24-bit ADC
SD Card Adapter
29
Mini Oscilloscope
evive can be used as mini oscilloscope to visualize voltage and current
measurements. Is has lots of function like scaling voltage level, time scaling
to see the reading in better way, trigger to start the measurement at some
set value, scanning modes like single or continuous, offset, save readings
to SD card and send data to computer.
2 Channels
Time Scaling
30
Internet of Things
The IoT hub contains ports for the ESP-8266, HC-05 and XBee modules,
which provides WiFi, Bluetooth and RF connectivity. The modules can be
plugged in directly and used.
Bluetooth (HC05)
Wi-Fi ESP8266)
XBee
Status Indicator
32
Beta Function Generator
evive is also a mini-function generator with a 12-bit DAC and an IIC
interface. The pre-defined menu offers generation of sine, square,
triangular and sawtooth waves upto 530 Hz and 2.5V amplitude.
Sine Wave
Triangular Wave
Square Wave
Saw-tooth Wave
33
Arduino Core Interface
The Magic Lid gives access to the entire Arduino Uno pinout which can be
used for Uno shields. 28 Digital I/O, 10 Analog In, 15 PWM and 6 interrupt
pins are accessible through the Magic Lid. The MEGA’s SPI, IIC and TTL
interfaces are also available. evive also has two 3.3V digital I/O for your
3.3V CMOS logic level devices.
PWM Pins
Interrupt Pins
34
Serial Pins
3.3V CMOS
IIC
SPI
Physical
evive is compact, light-weight and drop-safe. VESA-compatible 75mm
mounting holes are provided to mount evive wherever you need. Although
35
evive has a mini-breadboard inside its magic lid for small circuits, you can
attach your regular-size breadboards to evive by the breadboard mounts
provided.
Size
Weight
Mount Holes
Cooling Vents
Breadborad Mount
36
What you get with evive IoT Kit?
1 x Flathead Screwdriver
37
2 x Light Dependent Resistors
1 x DC to Terminal Block
38
4 x 5V Relay
39
1m x Feeder Pipe
2 x Drip Emitter
2 x T Connector
2 x Emitter Stakes
40
1 x Teflon Tape
41
1 x EU-US Converter (Provided on Request)
42
Multiple Programming Platforms
Compatible with several of hobbyists’ favorite programming platforms like
the Arduino IDE, PictoBlox, MATLAB, and Python among others.
43
SENSORS
sensor is a device that produces an output signal for the purpose of
sensing a physical phenomenon.
In the broadest definition, a sensor is a device, module, machine, or
subsystem that detects events or changes in its environment and sends the
information to other electronics, frequently a computer processor. Sensors
are always used with other electronics.
A sensor's sensitivity indicates how much its output changes when the
input quantity it measures changes. For instance, if the mercury in a
thermometer moves 1 cm when the temperature changes by 1 °C, its
sensitivity is 1 cm/°C (it is basically the slope dy/dx assuming a linear
characteristic).
Sensor deviations.
Since sensors cannot replicate an ideal transfer function, several types of
deviations can occur which limit sensor accuracy:
Since the range of the output signal is always limited, the output signal
will eventually reach a minimum or maximum when the measured
property exceeds the limits. The full scale range defines the maximum
and minimum values of the measured property
The sensitivity may in practice differ from the value specified. This is
called a sensitivity error. This is an error in the slope of a linear transfer
function.
If the output signal differs from the correct value by a constant, the
sensor has an offset error or bias.
Nonlinearity is deviation of a sensor's transfer function from a straight
line transfer function. Usually, this is defined by the amount the output
differs from ideal behavior over the full range of the sensor, often noted
as a percentage of the full range.
Deviation caused by rapid changes of the measured property over time
is a dynamic error. Often, this behavior is described with a bode
plot showing sensitivity error and phase shift as a function of the
frequency of a periodic input signal.
If the output signal slowly changes independent of the measured
property, this is defined as drift. Long term drift over months or years is
caused by physical changes in the sensor.
44
Noise is a random deviation of the signal that varies in time.
A hysteresis error causes the output value to vary depending on the
previous input values. If a sensor's output is different depending on
whether a specific input value was reached by increasing vs. decreasing
the input, then the sensor has a hysteresis error.
If the sensor has a digital output, the output is essentially an
approximation of the measured property. This error is also
called quantization error.
If the signal is monitored digitally, the sampling frequency can cause a
dynamic error, or if the input variable or added noise changes
periodically at a frequency near a multiple of the sampling
rate, aliasing errors may occur.
The sensor may to some extent be sensitive to properties other than the
property being measured. For example, most sensors are influenced by
the temperature of their environment.
All these deviations can be classified as systematic errors or random
errors. Systematic errors can sometimes be compensated for by means of
some kind of calibration strategy. Noise is a random error that can be
reduced by signal processing, such as filtering, usually at the expense of
the dynamic behavior of the sensor.
Resolution
The sensor resolution or measurement resolution is the smallest change
that can be detected in the quantity that it is being measured. The
resolution of a sensor with a digital output is usually the numerical
resolution of the digital output. The resolution is related to the precision with
which the measurement is made, but they are not the same thing. A
sensor's accuracy may be considerably worse than its resolution.
45
Arduino blink and the Fade
46
Schematic diagram
47
We know the Power P = V * I
So resistor power drop is 3 V * 0.02 A = 0.06 W
So we can choose a 0.25 W resistor
3V
2V
Blink code
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
48
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the
voltage LOW
delay(1000); // wait for a second
}
49
Fade
// Variable Declaration
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
50
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
51
Example code for library function
/*
LiquidCrystal Library - Hello World
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
52
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
53
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
54
Evive Blink
#include <evive.h>
void setup() {
//put your setup code here, to run once:
pinMode(13, OUTPUT);
void loop() {
//put your main code here, to run repeatedly:
digitalWrite(13, true);
delay(1 * 1000);
digitalWrite(13, false);
delay(1 * 1000);
}
55
Evive, Dabble and pictoblox Light on off
56
57
HC-05 pinout, specifications, datasheet and HC05 Evive
connection
HC-05 Bluetooth module is a Bluetooth to serial converter that connects microcontrollers
(like Arduino) to other Bluetooth enabled devices. HC-05 pinout and specifications are given
below.
58
2. VCC Used to power the Bluetooth module. Give 5V / 3.3 V to this Pin.
Connect this pin with the RXD pin of the Microcontroller. This pin
transmits Serial data (wireless signals received by the Bluetooth
4. TXD
module are converted by module and transmitted out serially on this
pin)
Connect this pin to the TXD pin of the Microcontroller. The HC-05
5. RXD Bluetooth module receives the data from this pin and then transmits
it wirelessly.
HC-05 Specifications
59
Bluetooth protocol: Bluetooth Specification v2.0+EDR (Enhanced Data Rate)
Frequency: 2.4GHz ISM band
Modulation: GFSK (Gaussian Frequency Shift Keying)
Emission power: ≤4dBm, Class 2
Sensitivity: ≤-84dBm at 0.1% BER
Speed: Asynchronous communication: 2.1Mbps (Max) / 160 kbps, Synchronous
communication: 1Mbps/1Mbps
Security: Authentication and encryption
Profiles: Bluetooth serial port
Supply Voltage: +3.3V to 6.0 V
Supply Current: 30mA
Working temperature: -20 ~ +75Centigrade
Dimension: 26.9mm x 13mm x 2.2 mm
HC-05 Bluetooth module follows the IEEE 802.15.1 standardized protocol, through
which one can build a wireless Personal Area Network (PAN). It uses frequency-
hopping spread spectrum (FHSS) radio technology to send data over the air.
60
61
62
63
//This c++ code is generated by PictoBlox
#include <evive.h>
//Included Libraries
#include <Dabble.h>
void setup() {
//put your setup code here, to run once:
Dabble.begin(115200);
pinMode(13, OUTPUT);
void loop() {
//put your main code here, to run repeatedly:
Dabble.processInput();
if(Terminal.compareString("light on")) {
digitalWrite(13, false);
}
if(Terminal.compareString("light off")) {
digitalWrite(13, true);
}
}
64
Pulse width modulation
65
66
67
//This c++ code is generated by PictoBlox
#include <evive.h>
void setup() {
//put your setup code here, to run once:
pinMode(9, INPUT);
pinMode(13, OUTPUT);
void loop() {
//put your main code here, to run repeatedly:
68
Basics of Electrical and Electronics
Voltage
i.e. V
or V
where dw is the small change in energy
and dq is the small change in charge.
Where energy (W) is expressed in joules (J), charge (Q) in coulombs (C),
and voltage in (V). One volt is the potential difference between two points
when one joule of energy is used to pass one coulomb of charge from one
point to another.
69
Current
- V +
The movement of electrons from one end of the material to other end of the
material constitute an electrical current denoted by I. The conventional
direction of current flow is opposite to the flow of – ve charges
i.e. the electrons.
70
Expressed mathematically I
I
where dq is small change in charge of electrons and dt is small change in
the time.
71
Power and Energy
Energy is the capacity for doing work. i.e. energy is nothing but stored
work. Energy may exist in so many forms such as mechanical, chemical,
electrical and so on. Power is the rate of change of energy, and is denoted
by P. If certain amount of energy is used over a certain length of time then
P= = *
= V * I = VI W
Energy is measured in joules (J), time in seconds (s), and
power in watts (W).
72