Sie sind auf Seite 1von 211

Table of Contents

Arduino UNO
ATMega328
What is this Arduino?
Starting Eclipse
Das blinkenlights
Switching to Release Build
How to Optimize Arduino?
Uploading your Program to the Arduino
Final result!
Interfacing LCDs with Arduino
Introduction
Character and LCD Graphics
Character LCD
LCD Graphics
Code Project
Ski
Ski2
Conclusion
Introduction to the Arduino
Hardware Platform
Introduction
Background
Blinking
Metronome
YYZ
Debugging Arduino Sketch
Conclusion
Automation Solution Using
Arduino
Motivation
Arduino Mega 2560
Wiring Setup
Using Code Arduino
Code Test Results Arduino
Password Safe Built With Arduino
Introduction
Hardware
Using code
Arduino UNO

How to enable relays or more on


Arduino series
Here's my quick tutorial on how to
connect relays to Arduino, special
relay switch 5 pin electromagnet.
Figure 1

If you can use a relay that functions


as a switch for AC voltage, for
example to turn on or off an
electrically powered app such as a
lamp, 1 phase electric motor, a fan
and so on, be careful when it comes
to the voltage you try to learn how
to connect properly before insert its
AC voltage.
You will see Arduino on the left
that provides power for relay and
its accompanying components with
DC voltage, and on the right side is
red LED as indicator turns on the
battery itself. (You can get to see
the power of LEDs by Arduino).
nitial step, you will use digital pin
number 8 Arduino to send signal to
relay, pass other components. So
there hook pin number 8 to 1 kohm
resistor. Why resistor, because the
transistor you are using will capture
the signal from pin 8 can not handle
the full 5v voltage of digital pin,
voltage of pin is very weak then it
needs to raise by adding auxiliary
voltage.
Try to learn first about how to work
from a relay below before we
continue.
Figure 2

Next, transistor as driver why use


one? Since we can not operate relay
with signal from digital pin only - it
will not be enough to switch
directly then to switch internal
magnetic switch relay. So connect
the transistor to the image, with:
Figure 3
Figure 4
for more details you connect on
transistor there are 3 pins that is the
base of the collector and emitter,
middle pin - base - connected to the
digital pin through the resistor,
emitter - left side of the transistor,
when you see the flat side of the
component - connected to ground
and collector - right side transistor -
go to rectifier.

What is a rectifier? Well, it is a


diode that keeps the curcuitry from
the electrical current from relay
when it is turned off, as reversal
voltage is reversed when there is a
problem on relay coil and a sudden
change in the current flow rises
from the relay. For relays, it's like a
night-club bouncer that prevents
the inrush current from fine
transistors and Arduino - like "you
behave, you'll add a safety when it's
necessary and easy to install", that
is. It's like a one-way street for
now. If you just tinker and
reproduce this or a different
example you can go without it but at
your own risk, better do not do it.
Figure 5

Associate the rectifier (series) to


one end of relay coil, and hook the
other end of the coil to power. This
is really a coil in a relay
,empowering coil creates a
magnetic field in relay as a contact
puller switch, more clearly 'creates'
a magnet if you want, which pulls
the metal pin inside the relay cage,
which in turn touches one of two
small contacts (on and off) and
make connections between them.
Figure 6
That's part of the Arduino tutorial.
Now we need something so that
relay can actually burn and die. In
this case, red LED, powered by
battery voltage. Connect the battery,
LED as shown in picture (do not
forget resistors unless you are
willing to sacrifice one or two
LEDs on trial-and-error changes),
and then connect the relay.
When connecting relays, hook the
'common' pin to ground. This pin is
one that holds one end of a metal
pin that touches one of the contacts -
usually labeled on (NOT) and
usually closed (NC). View
datasheets of your special relays to
make sure they are properly
connected - not always like this
label - NO, NC, and COM (for
Common) written on the relay itself.
try to see in Figure 2.

The way relay is used, if you want


the relay to turn off something when
controlled from arduino, you have
to connect your app resources - in
this case the battery for LED as
indicator - to the normally opened
(NO) pin. If on the other hand you
want to use a relay to turn
something on, you have to connect
the power source to a normally
closed (NC) pin. Try to use relay as
needed load.
This image below shows the pin
orientation of the relay board if you
have it if you can not use a regular
relay.
Figure 7
If you associate a sample-board on
protoboard, you should be able to
do what I do: Play the Arduino
sketch that turns the relay on and off
every 15 seconds. Here's an
example code:
Download Code
That's it - that's how you connect
relays to Arduino, turn on and off!
Hopefully this simple project can
help. Good luck
Arduino (with ATMega328)

This article will help how you will


better understand and increase the
knowledge developed with
Arduino.
What is this Arduino?
Immediately answered yes.
Arduino is an open-source
electronic prototype platform based
on software and software that is
flexible and very easy to use. This
is for hobbyists, programmers, fans,
and anyone interested in creating
objects or environments more
interactive.
Actually Arduino has many choices.
With this particular context, it
probably means one of the ones we
discuss
Arduino - Platform hardware
("board")
Arduino - Library abstraction
on WinAVR. WinAVR is a chain
of GNU tools (Compiler + C
Runtime library, etc.) For AVR
microcontrollers used on
arduino boards ("software")
Arduino - " IDE" (We use
Arduino 19)
Here is a picture of special variant
of Arduino that I use (This is called
Freeduino serial board):
Figure 8
Figure 8 Freeduino-serial board
(with ATMega328)

Let me show you something


interesting and how each step will
help you to finish it. This is it, but
remember to go back to maintain
your health do not get late to eat
because busy in Arduino.
As a novice programmer, you will
soon realize that how early I
understand about Arduino IDE
makes you more curious. All you
need is a stronger set of tools. I
recommend using WinAVR +
Arduino Library + Eclipse
combination and this is what we
will discuss in the rest of this
article.
With Eclipse softwere, you'll be
simplified for code completion,
better code navigation, syntax and
all other codes

So from now onwards I'm assuming


that you've grown accustomed to
amazing Arduino development. If
not, go ahead and do (not to be too
long in thinking) then go back for a
better deal or just follow it if you
do not mind a bit of tension, throw
away with a cup of coffee. I'll
show you the way. Well, here's the
steps to Arduino project.
Download Eclipse (about 90
MB). Unzip it to C: \ Misc \
Eclipse
Download Arduino IDE. Unzip
to C: \ Misc \ arduino-0019
Download the latest version of
WinAVR. Unzip it to C: \ Misc \
WinAVR
Download Eclipse AVR plug-in
and install (follow the
instructions on their website)
Starting Eclipse and Trying
a Sample Program

1. Mulai Eclipse
Figure 9
2. Close the welcome page by
clicking a cross on the tab to
reveal the actual working
environment.
Figure 10

3. Start a new project by clicking


"File-> New-> C ++ Project".
Select the project type "AVR
Cross Target Static Library" and
fill the project name into
Arduino. We will now compile
the Arduino source file into
Static Library for later use, then
click finish.
Figure 11

4. Use Windows Explorer to enter


C: \ Misc \ arduino-0019 \
hardware \ arduino \ cores \
arduino, select all the code files
and place it into open Arduino
project in Eclipse. Notes only
include files with .c, .cpp and .h
.
Figure 12

5. Next click ok in the following


dialog (accept default copy
option).
Figure 13
6. Now create the project by right
clicking on it and select "Build"
from the context menu. Try to
see there are 10 build errors.
Figure 14
7. Problem will be solved together,
follow the fix step in a moment.
Right click on the project and
select "Properties" and go to
option "C / C ++ Build ->
Settings-> AVR Compiler".
Click on the "+" icon (after
selecting the "Directory"
option).
Figure 15

8. Click on "Workspace ..." button


and add project directory "$
{workspace_loc: / $
{ProjName}}" as the one-time
inclusion directory for "AVR
Compiler" and again for "AVR C
++ Compiler"
Figure 16

9. Right click on project and select


"Properties", then select "AVR->
select Hardware target" and then
set the MCU Type option to the
Microprocessor used on your
Arduino board along with the
crystal frequency included. it is
ATmega328P and 16,000,000
respectively. Then click ok.
Figure 17

10. Now create your project again


and build success you get this
time. Although you may get a lot
of warnings and just ignore it for
now.
Das blinkenlights

11. Next step goes to "File-> New->


C ++ Project" as before, but now
select "AVR Cross Target
Application" as project type and
set project name to
"BlinkenLights"
Figure 18

12. Right-click on the BlinkenLights


project and select "New-> File",
set the file name to Main.cpp and
then click Finish.
Figure 19

13. Then add the following C ++


code to Main.cpp:
14. Copy code below
15. Now compile project. looks a
lot of mistakes!
Download Code
Figure 20

16. We recommend fixing this


problem Right click on the
"BlinkenLights" project and
select "Properties" and go to the
"C / C ++ build-> Settings-> Avr
Compiler-> Directories" option
and click on "+" icon.
Figure 21

17. Then click the "workspace ..."


button on the next dialog and then
select Arduino-> Debug in sub-
next dialog.
Figure 22

18. Then Click ok once you verify


the path.
Figure 23
19. Do same for "C / C ++ build->
Settings-> Avr C ++ Compiler->
Directories"
20. Go to "C / C ++ build->
Settings-> Avr C ++ linker->
Library" and set following
options.
Figure 24
21. Now compile BlinkenLights
project again.

Figure 25

So far you feel better now, but we


still have one mistake to do. This is
a linker error. Linker complains
here that it can not find an
implementation for a function called
__cxa_pure_virtual anywhere
though it is being referenced / used
in other parts of the code. Problem
is you're just getting started and you
have not seen all codes used behind
scenes.
Suffice it to say a function is
required by C ++ runtime to decide
what needs to be done when
someone calls a pure virtual
function directly. As you recall from
your transactions with C ++, pure
virtual functions can not be called
directly without applying across
multiple derived classes. Well in
this case, classes with pure virtual
functions can not be used at all but
the C ++ runtime likes to be
prepared for any and all
possibilities.
Advanced compilers will issue
exceptions from this function to
signify illegal operations but since
we do not have them on the
WinAVR platform, all we can do
now is prevent further damage from
being done by inserting a never-
ending loop (assuming the program
is running collide in the first place
because it has done the impossible
by calling a pure virtual function
directly!)
Note: This needs to be done just to
build debugging. This function was
not used in the release release of
Arduino. Building a rigged debug
fails quickly so that point of failure
is as close as possible to place
where problem really is.
So here's how we get rid of the
above error.
22. Add a new .cd file to the
Arduino project (it should be
noted .c and not .cpp). Call it
missing.c and paste the following
code in it and create two more
projects. Errors must be lost.
Note You need to build an
Arduino before you can build
BlinkenLights.
Download Code
23. When switching to the "Console"
panel, you can see the result of
running the Avr-size command in
a self-generated file.
Figure 26
Approximately 62% Slightly
flashed led programs occupy the
overall program memory available.
But do not worry, we're in the form
of debugging and such hacking is
equivalent to the course. You'll get
better results when you switch to
releasing builds.
Switching to Release Build

24. Right-click on the project and


select "Build configurationations
-> Set Active-> 2 Release". Do
this for all projects. Also let me
know if you find a way to do this
for all projects at once.
Note: You need to reassign all
settings for release version as you
did to build the debug to make it
compiled.
Figure 27

About 18% more to be fixed for


BlinkenLights which is still too
much.
Premise Optimization Is Not
the Root of All Evil?

25. Then how to do The following will


ensure that you only pay for the
functions and parts of the data
actually used in the program. Add
following additional flags to C and C
++ compilers in all projects.

Download Code
Figure 28
26. Add and following flag to the
link options in all projects.

Download Code
Figure 29

27. Rebuild them (in the correct


order of first Arduino, second
BlinkenLights.)
Figure 30
Uploading your Program to
the Arduino

To be able to upload your first Arduino


program created within the comfortable
Eclipse limits.

28. Right-click on the BlinkenLights


project and select "Properties".
then go to AVRDude page and
click new.
Figure 31

29. Fill in the form as follows:

Configuration name: Arduino


Software Programmer:
Arduino
Overwrite default port: \\. \
COM3. Replace COM3 to any
port connected to the Arduino
hardware.
Override default baud rate:
19200. Replace 19200 tailored
to your board manufacturer /
person whos uploaded Arduino
boot loader in your board.
Figure 32

30. Select Arduino as the


programmer in AVRDude
settings and select OK.
Figure 33

31. Followed by menu on the AVR


toolbar button to upload your
program to the board and then
click.

Figure 34
32. You will see something like the
following in the console window
Download Code
33. If the program code runs
correctly, the on-board test LED
(usually red) should now start
blinking around 1 blink / sec.
Congratulations!
Final result!

So how to use Eclipse for AVR


development. But this is just the
beginning. little exercise will make
you grow with Arduino should be a
good place to start further
exploration and get a sophisticated
project in it.
Interfacing LCDs with
Arduino

Interfacing Arduino with character


LCD and graphic LCD
Introduction
Arduino fans in existing hardware
platforms, it can be applied to an
LCD and there is soo Arduino
wiring to the character LCD and
graphic LCD, and includes stats
and animation menus to showcase
the capabilities of each screen.
Character and LCD
Graphics
Found on the Arduino platform,
there are a variety of components
that can be used for \ Arduino -
everything from LEDs, to medium-
sized Ethernet shields, to over-the-
top tank shields (marketed for
almost $ 200!). Moments for
Arduino. I noticed that LCD was
quite cheap so I bought the
character LCD $ 10 16x2, and
Graphics LCD 128x64 $ 18.
Characteristics of LCD and LCD
are devices that have different APIs
and APIs when to move them. Print,
both devices are supported by
Arduino community. For my LCD
character, I use LiquidCrystal
material, and for my graphic LCD, I
use KS0108 Graphic LCD material.
Character LCD
How to connect the character LCD
and programming is very easy and
so far have not found problem. I am
only possible and the wiring
diagram in Arduino Character LCD
Tutorial and everything works as
expected. After running sample
sketch of LCD_example, I wrote a
sketch to take advantage of the LCD
I call HelloCodeProject.
Download Code
Image 1
Download Code
Image 2
LCD Graphics
Try to apply with the running
display with LCD graphics I did not
run as smoothly as done by the LCD
character. After free cable (all 20
of them!), ExampleGLCD sample
sketches that come with KS0108
materials do not work. After a
long thought, I discovered that the
release version of the KS0108
material did not work with my LCD
and I needed a beta version of
library (which has since been
promoted to official Release 2
library). Once it's settled,
everything works fine.
CodeProjectLogo
Image 3
With sample sketch of
ExampleGLCD running, I started
writing my first graphical LCD
sketch, CodeProjectLogo. First
thing to do is write a .NET console
application that converts a 1-bit
monochrome image into an array.
The oldest makes the arrays "1" and
"0". Unfortunately this is a problem
because the bool array is large and
causes resulting sketch to be too
large to fit in the Arduino.
Next step is to compress the image
size by using long run coding.
Since many pixels of image are
repeated, I think this might be an
efficient way to reduce the data
needed for image size. The format
of each line is:

Download Code
Then it's marker.1 shows the first
run of the black line, 0 points to the
first run of the white line, and -42
indicates the array is complete. Int
both show the length and turn back
and forth between black and white
until -1 is found, which indicates
the end of the line. For example, if
there is:

Download Code
.64 black pixels will be drawn, then
32 white pixels, then 32 black
pixels.

Size of the sketch works better and


is now small enough to be uploaded
to the Arduino, but the arrangement
is too large to collect Arduino.
When I enter the entire array,
Arduino falls and keeps repeating
itself, and I find if I only put 1/4 of
the total array, it works fine, so the
RLE approach does not work.

Found there are a large amount of


data needs to be stored in flash
memory using PROGMEM
keyword. By using PROGMEM,
the raw array is declared as:
Download Code
Data is then extracted from flash
memory via pgm_read_byte_near
():

Download Code
And then make one more pixel than
time via GLCD.SetDot ().

Storage of data in flash memory, no


complaints learned that the beta
version of the KS0108 library also
includes a new function,
DrawBitmap (). Second version of
CodeProjectLogo (just a comment
from #define USE_SET_DOT
statement) assembles the array as:

Download Code
And draw a bitmap via
GLCD.DrawBitmap ():

Download Code
Put it into BMP_Dump project (C
# Visual Studio 2008 solution). It's
not too powerful (no error
checking) but no work done, it has
forgotten all 3 formats in (raw bool
array, compressed RLE int array,
and paged channel int array) in case
anyone wants to experiment with
different formats are generated and
display different images in their
graphic LCD (copy and paste) the
array after it is generated).
Ski
Image 4
Graphical LCD sketch is a game
called Ski, which is a game that
leads to the 8-bit games published
on computers in 80s, such as
Compute !, A.N.A.L.O.G., and
Antic. it is very simple where one
tries to stay within the limits, that is
skiing that can be used and use the
potentiometer to control direction of
the player. I must point out that not a
game programmer, Ski, a very
smooth game, and just a proof of
concept, but it shows what potential
can be done. For this sketch, in
addition to the 128x64 LCD
connected to your Arduino you will
need a push button connected to
digital pin 2 and a 10K Ohm
potentiometer connected to the
analog pin 5.
Image 5
Image 6
Note: This image 6 is not very good
(due to poor camera quality). I
lighten the image a bit but some of
the cable is still a bit hard to see.
The ground cable coming out of the
project board will enter the
Arduino ground pin, and ground
wire from the potentiometer enters
project board board ground.
Because the angle of photo was
taken (and contrast), in the image it
looks like a ground wire from a
potentiometer also goes into
Arduino ground pin. If you enlarge
the image, cord is a bit clearer.

Will be displayed first served with


start screen. After he presses the
button, game starts and a random
track is generated. Tracks, as well
as players, can have direction
(slope) -2, -1, 0, 1, or 2:

Image 7
This lesson is held in a circular
memory buffer (g_course) and the
current position is tracked by
g_nCircularBuferPosition. At the
end of every 16 movements, a new
tilt is calculated:
Image 8
(The source code for Skiing is too
long, so please read the zip project
file for the entire source code.)
Ski2

With the first Ski version, I draw


each pixel from each line. As a
result, game is too slow, so I
revised code to just draw the pixels
that have potential changes and
focus on drawing the current edge
+/- 3 pixels:
Download Code

And i find this makes the game more


playable (speed increases so much
so i need to add a delay () call).
Conclusion
How to connect various hardware
inputs and outputs with Arduino,
and has shown the potential that can
be developed. I consider this
component as basic building block
from which one can mix and match
and create new and unique devices.
The potential is huge and limited
only by one's imagination. For
inspiration develop yourself about
what can be done with Arduino
going forward.
Introduction to the Arduino
Hardware Platform

Introduction to Arduino hardware


platform
Picture 1
Introduction

For discussion this time about


hardware platform Arduino. If
you're new to Arduino project first
and would like to know more, it's a
cheap and flexible Open source
hardware platform and is great for
creating interactive projects. Pin I /
O, some analog input pins (number
of digital and analog pins vary from
model to model), easy to set up and
use, have a multi-platform (though
somewhat limited) IDE, and are
programmed using C / C ++.
Schematic and board design is
Open Source so you can develop it
yourself or buy a cheap prebuilt
model from some distributors.
Arduino community is very broad
and supportive. You can connect
any input sensor (such as wah
potentiometer, light sensor,
microphone, MIDI In port,
accelerometer, push button,
thermometer, etc ...), and have it
control every output device (such as
LED, LCD character, graphic LCD,
port MIDI Out, speaker, etc ...),
Arduino is very accommodating and
easy to develop in its application ..
Background

This time we will try to make a


special MIDI expression pedal. As
a beginner to be aware of is What I
want to build will be trivial to
implement in software, but I want to
build a self-contained device that is
portable and independent.
Previously you have to understand
about basic electronics such as
basic about resistor, capacitor, and
op amp, to be connected on arduino
platform.
I found environment and IDE for
arduino, but debugging levels,
function navigation, and intellisense
are not available). However, where
the programming environment is
less it more than made up for the
hardware itself. Each model has a
number of digital inputs and outputs,
the number of inputs and outputs is
different from model to model so it
can be tailored to the needs of the
project, ability to be supported
either by USB or unregulated power
supply (Arduino can be easily
directly supported by 9VDC power
supply or 9V Battery, and does not
even require a power regulator to
crash voltage from 9VDC to 5).

Large Image
It's time to start learning more
about Arduino we start.
Blinking

Your can visit the Arduino website


which has a very easy to follow
instructions on how to set up the
software, how to connect hardware
(it's just a matter of connecting
USB cable and telling the IDE of
serial port where the device is
active), and how to test your first
sketch to make sure everything goes
right (in Arduino environment each
project is called a sketch). You will
see many examples of Arduino's
web programming and the website
also has a very active message
board where developers can ask
questions and post solvable
problems.

The first step is to connect your


hardware and configure your IDE,
then to load "Hello World" in the
Arduino universe. IDEs are sent
with a number of standard sketches,
one of which is called Blink:
Picture 2
You should see the following code
after it is loaded

Download Code
On each of the common functions -
setup () and loop (). setup () is
called when Arduino activates /
resets and initializes, and loop () is
repeatedly called repeatedly. At this
point, if there is no problem and
connect correctly, you are ready to
upload your first sketch. Just click
the "Upload to I / O Board" button
(this compiles and then uploads the
sketch):
Picture 3
After the sketching peoses are
transferred, you will only see the
LED on the micrcontroller board
blinking and off. You can use LEDs
soldered to the Arduino board:
Picture 4
Can also connect the LED to the
ground pin and pin 13.

For a while, you simply insert the


LED into the Arduino. Insert the
LED with short legs to GND and
long legs to pin 13:
Picture 5
For permanent installation, LED
will burn if the resister is not
inserted into the circuit. Connect the
Arduino to the board where project
board and add 1K Ohm resistor and
LED as safety.
Picture 6
Metronome

The next thing I do is create a new


sketch based on Blink and called
Metronome. In Metronome, I have
set the delay between blinking to a
function of tempo:
Download Code
Changing the tempo requires code
changes, compilation, and then
upload. To overcome this and make
the design more flexible, we can
add potentiometers to control the
tempo, Relax do not rush and will
delay the addition of potentiometer.
YYZ
Not satisfied with the simple
flashing metronome (and being a
drummer), I decided to make
something more rhythmic and
syncopated - YYZ. The YYZ song
by Rush (from Moving Pictures
album) is instrumental and begins
with the letter 'YYZ' which is
played in Morse code on the bell
(YYZ is the airport's identification
code for Toronto airport - the band's
birthplace). YYZ sketches visually
play YYZ in Morse code:
Download Code
Heard the intro tempo was initially
104 beats per minute, but I found the
tempo too fast in its program to
select the rhythm, so I lowered the
tempo to 100 beats per minute.
Debugging Arduino Sketch
Although IDE does not support line-
level debugging, it supports serial
debugging. In the setup () function,
you need to add a call:

Download Code
Arduino and speed to transmit
serial data on. In your code you will
then add Serial.print () and
Serial.println () statements to be
sent back to the IDE. To view serial
data that is sent, just click on the
"Serial Monitor" button.

Picture 7
When serial is active, the output is
displayed in serial output panel.
Picture 8
Though simple but it works and it's
better than nothing.
Conclusion
Early Adruino lesson has finished
this article as a basis for further
reading, you should check out
Arduino home page, Arduino start
page, and some user-generated
projects on the Arduino user project
page.
Automation Solution Using
Arduino
Automation solution using Arduino
Motivation
Most of the automation is needed in
the production world, you may
always think how to develop a
manual machine can be made
completely automated (no external
interface).

For example, an old product that


operates by pressing multiple
buttons or switches.

With this Arduino lesson there will


be growing in automation systems.

Simple and inexpensive solutions


can be achieved using an Arduino
controller.

Basis of this automation system we


will learn about how to work from
the relay switch box and control it
externally using your PC Com port.

What to need
Arduino controller (I use
Arduino mega 2560) - 15 $ on
eBay.
8-Channel Relay Module for
Arduino - $ 10 on eBay.
40 wire 2 $ on eBay.
Arduino SDK -
http://Arduino.cc/.
Brief Explanation of Hardware.
Relay Module.

This module has 8 relays, need to


be fed by 5V of arduino mega board
to operate.
There is an 8-pin output to control
each relay separately, when
applying the logic "0" to each relay
port in question open.
Relay Controller
Arduino Mega 2560
ATmega2560-based
microcontroller board has 54
digital input / output pins, 16
analogue inputs, 4 UARTs
(hardware serial port), USB
connection, power jack and reset
button. It contains everything
needed to support microcontroller,
just connect to computer with USB
cable then transfer program file and
save it on arduino ..
Arduino Mega 2560
Wiring the Setup
VCC 5V from Arduino to VCC
pin of relay shield.
GND from Arduino to pin GND
of relay shield.
8 cables from the Arduino board
to the relay shield as follows:
Pin 52 from Arduino to pin 1 on
the relay shield
Pin 50 from Arduino to pin 2 on
relay shield
Pin 48 from Arduino to pin 3 on
relay shield
Pin 46 from Arduino to pin 4 on
relay shield
Pin 44 from Arduino to pin 5 on
relay shield
Pin 42 from Arduino to pin 6 on
relay shield
Pin 40 from Arduino to pin 7 on
relay shield
Pin 38 from Arduino to pin 8 on
relay shield.
Wirring Arduino
Using Code Arduino
Let's specify two simple commands:

Open relay must be + x with x is


the port number.
Closing relay should be -x with
x is the port number.
First, we define the relay port
number as connected on the cable:
Download Code
Then, we initialize the port as
output:

Download Code
We need to assign logic "1" to the
pin so that all relays are off:

Download Code

We set the serial port to 19200 baud


and wait for connection:

Download Code
In the loop method, we read the full
line of the serial port and detect
whether it opens or closes
commands, for example:

Download Code
For each command, we detect the
status by detecting the first
character of the command (+ or -)
and the second character for the
specific relay number. then we call
"SetStatus" with parameters
extracted.
Download Code
Then SetStatus method has two
parameters:

Boolean on - first command


character (+ or -), open or close
char relayNumber - port relay to
open or close
The full code is as follows:
Download Code
Code Test Results Arduino
Testing Code
Connect the Arduino board to
your PC
Open a new project using the
Arduino SDK and paste the
code.
Be sure to choose the correct
COM Port.
Select Arduino Mega Board
2560 of board type.
Download the code to the
Arduino Mega Board.
Finish Test
Open the serial monitor in the
Arduino SDK.
Choose the right baud rate
(19200).
Try writing "+1" or "-1" to
open / close relay 1,
Then press and send button.
Note : Now you can connect via
PC with the help of RS232.
Password Safe Built With
Arduino

How to create a secure device


password and login system with
rack components.
Introduction
Use a secure and simple password
with an Arduino-based password
manager.

More clearly on a concept in


making the system of government.
Hardware
The core of hardware is Arduino
Leonardo. Leonardo is built around
the microcontroller ATMega U32,
which has USB hardware
capabilities. Optional, Arduino Due
or Yún can be done, because the
controller you have on board also
has USB capability.
ATMega U32
Other Arduino models do not
match. Although each Arduino is
programmed with USB, only
models that use the original USB.
On board, such as Uno, a special
USB-Serial translation chip,
Disadvantages you can not use USB
devices such as keyboard or mouse.

A basic introduction is keyboard


emulation. Device stores the login
password for various sites in the
microcontroller's FLASH memory,
and by pressing a button, it will
enter the selected keywords. The
device acts like a keyboard, and it
will output keywords into selected
word box very quickly.

Because the device acts like a


keyboard, solution is completely
free platform. ease of use by
operating from Windows, Linux,
OS-X, or even Phone, and Tablet
regardless of operating system.
Can also use LCD keypad, can be
purchased from Chinese resellers
in e-bay or aliexpress.

Each reseller has its own version,


display screen can vary, but
everything works the same way.

This Shield has a Hitachi LCD


compatible with 16x2 Characters
and 5 buttons compatible with
HD44780U. LCDs can be used with
LiquidCrystal material, which is
nice, since no additional libraries
are needed because it is larger.

It has only one analog input,


because they are connected like a
voltage divider.
Using code
Software uses a simple relay output.
At start-up the device will prompt
you to unlock. Lock unlock is a
sequence of buttons on the shield.
This can be configured in the
sketch, you can use any combination
of any length. However there are
only four words that constitute, so if
you really want to use many
combinations of numbers it can be 8
or more.
Picture 1
For precautions to create a stronger
brute force attack it features a down
key timer. Locking starts when you
enter 3 invalid lock code. It creates
a delay of 30 seconds, before you
can enter the agin code. You can get
out of here, by rearranging the
board, but it will take 5 seconds,
because Arduino bootloader.
Pictue 2
If you use 10 keys which is the total
number of combinations is 410, that
is 1 048 576. Now, let's assume that
your keycode is very strong, so we
should try each combination. Also
let us assume that the attacker is
very fast and can be a combination
of under 1 second, but on every 3rd
combination of him, to every three
to three takes 5 seconds, allowing
him to be 3 combinations under 7
seconds in theory. This means that
the attacker needs 2 446 677
seconds for the combination roll,
which is 28 days without sleep or
stop. In conclusion that if your
device is stolen, Ease of change
password can be longer

If you successfully unlock your


device, you can select an account
with up and down buttons. Pressing
select key sends saved password to
the computer.
Pictue 3

Large Image
Download Code

Thanks …….

Das könnte Ihnen auch gefallen