Nexus Automation Nexus Robot User manual

www.nexusrobot.com Robot Kits manual
NEXUS ROBOT
Looking to the future
Robot Kits User’s Manual
Nexus Automation Limited
ADDR: 2/F,Chengxi Building. 819 S358 Road. Shatou,
Changan, Dongguan, Guangdong, China
Robot Kits User’s Manual
Tel: +86-769-85301107

www.nexusrobot.com Robot Kits manual
Nexus Robot
A. Attention!! Please read this manual carefully before applying power on the
device.
B. Attention!! Do not use this device for military or medical purpose as they are
not designed to.
C. Attention!! Do not use over-voltage power supply ! ensure stable power
supply. if there is high-voltage pulse, may cause the micro-control module
permanent damage !
D. Attention!! This product is not waterproof feature, please keep or use it in a
dry environment ! Don't piled the weight on top of it .

www.nexusrobot.com Robot Kits manual
I
¾Arduino...................................................................................................................1
¾Introduction......................................................................................................1
¾Hardware ...............................................................................................................1
¾Specification ....................................................................................................1
¾Arduino Board Pinout......................................................................................2
¾Arduino 328 Features.......................................................................................2
¾Memory function ......................................................................................3
¾Input and Output PinMode........................................................................3
¾Communication.........................................................................................3
¾Configuration...................................................................................................3
¾Servo Power Select Jumper ......................................................................3
¾Motor Control Pin Jumper........................................................................4
¾Wireless Select Jumper.............................................................................4
¾Arduino IO Expansion Board ..........................................................................4
¾Features.....................................................................................................4
¾Software.................................................................................................................5
¾Before you start................................................................................................5
¾Applying Power........................................................................................5
¾Getting Started..........................................................................................5
¾Language Reference.........................................................................................9
¾Programming structure.....................................................................................9
¾Re-write Arduino bootloader.............................................................................10
¾FT232RL BitBang Mode AVR-Writer..........................................................10
¾Modify the Diecimila..............................................................................10
¾Downloading...........................................................................................11
¾Installing .................................................................................................11
¾Setting.....................................................................................................12
¾Testing and confirming...........................................................................13
¾Adjust PWM frequencies...................................................................................13
¾Simple Examples in Arduino 328.....................................................................15
¾LED control ...................................................................................................15
¾Button module................................................................................................16
¾Interrrupt control............................................................................................17
¾Digital Read Serial.........................................................................................18
¾Analog Read Serial........................................................................................19
¾Servo Motor Theory.......................................................................................19
¾Motor Control ................................................................................................21
¾Serial Port.......................................................................................................22
¾External device modules...................................................................................23
¾Dual Ultrasonic Sensor (DUS).......................................................................23
¾Introduction.............................................................................................23
¾Specification ...........................................................................................24
¾Dimension and Pin definition .................................................................24
¾RS485 Bus ..............................................................................................25

www.nexusrobot.com Robot Kits manual
II
¾Communication Protocols.......................................................................27
¾Sensor Connection..................................................................................29
¾Sensor Networking..................................................................................29
¾APC220 Module ............................................................................................30
¾Parameters...............................................................................................30
¾Kit list......................................................................................................30
¾This module used to connect PC port.....................................................30
¾Pin Change Interrupt..........................................................................................31
¾PinChangeInt Library.....................................................................................31
¾PID Control..........................................................................................................33
¾What Is PID....................................................................................................33
¾The Library ....................................................................................................33
¾Servo control Theory .........................................................................................34
¾The PWM signal............................................................................................35
¾Motorwheel..........................................................................................................36
¾Motorwheel Class Reference.........................................................................36
¾Class Motor Reference............................................................................37
¾Class GearedMotor .................................................................................43
¾Class MotorWheel ..................................................................................45
¾R2WD............................................................................................................49
¾R2WD Class Reference ..........................................................................49
¾Public functions ......................................................................................49
¾Private parameters...................................................................................62
¾R2WD_test..............................................................................................68
¾2WD platform with 3 SONAR ...............................................................71
¾Omni3WD......................................................................................................74
¾Omni3WD Class Reference....................................................................75
¾Public functions ......................................................................................76
¾Private parameters...................................................................................84
¾Omni3WD_test.......................................................................................86
¾Omni3WD platform with 3 SONARS....................................................89
¾Omni3WD platform with 6 SONARS....................................................93
¾Omni4WD......................................................................................................97
¾Omni4WD Class Reference....................................................................98
¾Public functions ......................................................................................98
¾Private parameters.................................................................................109
¾Omni4WD_test.....................................................................................112
¾4WD platform with 4 SONAR .............................................................115
¾Servo Motor.................................................................................................118
¾Servo_3WD platform with 3 SONAR..................................................122

www.nexusrobot.com Robot Kits manual
1
¾Arduino
¾Introduction
Arduino Controller is an All-in-One microcontroller especially designed for robotics application. Benefit
from Arduino open source platform, it is supported by thousands of open source codes, and can be easily
expanded with most Arduino Shields.Arduino can sense the environment by receiving input from a
variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The
microcontroller on the board is programmed using the Arduino programming language (based on Wiring)
and the Arduino development environment (based on Processing). Arduino projects can be stand-alone
or they can communicate with software running on a computer (e.g. Flash, Processing, MaxMSP).
¾Hardware
¾Specification
Atmega 168/328
14 Channels Digital I/O
6 PWM Channels (Pin11,Pin10,Pin9,Pin6,Pin5,Pin3)
8 Channels 10-bit Analog I/O
USB interface
Auto sensing/switching power input
ICSP header for direct program download
Serial Interface TTL Level
Support AREF
Support Male and Female Pin Header
Integrated sockets for APC220 RF Module
Five IIC Interface Pin Sets
Two way Motor Drive with 2A maximum current
7 key inputs
DC Supply:USB Powered or External 7V~12V DC
DC Output:5V /3.3V DC and External Power Output
Dimension:90x80mm

www.nexusrobot.com Robot Kits manual
2
¾Arduino Board Pinout
The picture above shows all of the I/O lines and Connectors on the controller, which includes:
One Regulated Motor Power Input Terminal (6v to12v)
One Unregulated Servo Power Input Terminal (you supply regulated 4v to 7.2v)
One Servo input power selection jumper
One Serial Interface Module Header for APC220 Module
Two DC Motor Terminals – Handles motor current draw up to 2A, each terminal
One IIC/TWI Port – SDA, SCL, 5V, GND
One Analog Port with 8 analog inputs – one input is tied internally to the supply voltage
One General Purpose I/O Port with 13 I/O lines – 4,5,6,7 can be used to control motors
One Reset Button
Jumper bank to Enable/Disable Motor Control
¾Arduino 328 Features
The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital
input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator,
a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to
support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC
adapter or battery to get started.

www.nexusrobot.com Robot Kits manual
3
¾Memory function
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM and 1 KB of
EEPROM (which can be read and written with the EEPROM library).
¾Input and Output PinMode
Each of the 14 digital pins on the Duemilanove can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a
maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In
addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are
connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising
or falling edge, or a change in value. See the attachInterrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI
library.
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.
¾Communication
The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other
microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial communication over
USB and appears as a virtual com port to software on the computer. The '8U2 firmware uses the
standard USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is
required. The Arduino software includes a serial monitor which allows simple textual data to be sent to
and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted
via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins
0 and 1).
¾Configuration
¾Servo Power Select Jumper
As most servo draw more current than the USB power source can supply. A separate servo power
terminal is provided to power the servo individually which can be Enable/Disable by the Servo Power
Select Jumper.

www.nexusrobot.com Robot Kits manual
4
When the Servo Power Select Jumper is applied, the servo is powered by internal 5V.
When the Servo Power Select Jumper is not applied, the servo is powered by external power source.
¾Motor Control Pin Jumper
Applying the Motor Control Pin Jumpers will allocate Pin 4,5,6,7 for motor control.
Removing the jumpers will release the above Pins.
¾Wireless Select Jumper
Applying the Wireless Select Jumper will allow the controller communicate via its wireless module such
as APC220. If no wireless module is plugged, this jumper does not make any difference.
Removing the jumper will disable wireless module and allows the sketch to be uploaded.
¾Arduino IO Expansion Board
To support RS485 interface or drive 4 motors, IO Expansion Board is available.
This Arduino compatible I/O EXpansion Sheild is intelligently designed to facilitate an easy connection
between an Arduino board (e.g. Arduino Duemilanove) and other devices such as sensors and RS485
devcices. In essence, it expands an Arduino controller's Digital I/O and Analogue Input Pins with Power
and GND. It is compatible with Arduino Mega and is a perfect companion of Arduino Dumilanove
(Atmega168 and Atmega 328).
¾Features
1. Supporting XBee (Xbee Pro)/Bluetooth Bee;
2. An unique RS485 output, supporting a RS485 device;
3. Separate PWM Pins, which are compatible with standard servo Connector;

www.nexusrobot.com Robot Kits manual
5
4. Supporting Bluetooth module, APC220 module;
5. Auto Switch between external and onboard power supply;
6. Supporting SD card (read&write - our SD card module is needed);
7. Supporting IIC/I2C/TWI connection
See: http://www.nexusrobot.com/product.php?id_product=51
¾Software
The open-source Arduino environment makes it easy to write code and upload it to the i/o board. It runs
on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing, avr-gcc,
and other open source software.
¾Before you start
Before you start there are somethings you will to attention.
¾Applying Power
This is one of the most important steps in getting the controller up and communicating with your host
controller. You must make sure that you apply power to the Power Terminal using the correct polarity.
Reverse Polarity will damage the controller. We are not responsible for such damage, nor do we
warranty against such damage. Make sure you take time to apply power correctly. Otherwise, it could get
costly for you!
Power from USB: Simply plug USB cable, and the controller is able to work. Please notice that the USB
can only supply 500 mA current. It should be able to meet the most requirements for LED lit application.
However it is not enough to power DC motors or servo.
Power from Motor Power Input: Simply connect the ground wire from your supply to the screw terminal
labeled “GND”, and then connect the positive wire from your supply to the screw terminal labeled “VIN".
NOTE: Maximum supply voltage cannot exceed 14V DC.
¾Getting Started
This document explains how to connect your Arduino board to the computer and upload your first sketch.
1 | Get an Arduino board and USB cable
In this tutorial, we assume you're using an Arduino Uno, Arduino Duemilanove, Nano, or Diecimila. If you
have another board, read the corresponding page in this getting started guide.
You also need a standard USB cable (A plug to B plug): the kind you would connect to a USB printer, for
example. (For the Arduino Nano, you'll need an A to Mini-B cable instead.)

www.nexusrobot.com Robot Kits manual
6
2 | Download the Arduino environment
Get the latest version from the download page.
When the download finishes, unzip the downloaded file. Make sure to preserve the folder structure.
Double-click the folder to open it. There should be a few files and sub-folders inside.
3 | Connect the board
The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from either the USB
connection to the computer or an external power supply. If you're using an Arduino Diecimila, you'll need
to make sure that the board is configured to draw power from the USB connection. The power source is
selected with a jumper, a small piece of plastic that fits onto two of the three pins between the USB and
power jacks. Check that it's on the two pins closest to the USB port.
Connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR)
should go on.
4 | Install the drivers
Installing drivers for the Arduino Uno with Windows7, Vista, or XP:
Plug in your board and wait for Windows to begin it's driver installation process. After a few
moments, the process will fail, despite its best efforts
Click on the Start Menu, and open up the Control Panel.
While in the Control Panel, navigate to System and Security. Next, click on System. Once the
System window is up, open the Device Manager.
Look under Ports (COM & LPT). You should see an open port named "Arduino UNO (COMxx)"
Right click on the "Arduino UNO (COmxx)" port and choose the "Update Driver Software" option.
Next, choose the "Browse my computer for Driver software" option.
Finally, navigate to and select the Uno's driver file, named "ArduinoUNO.inf", located in the
"Drivers" folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory).
Windows will finish up the driver installation from there.

www.nexusrobot.com Robot Kits manual
7
See also: step-by-step screenshots for installing the Uno under Windows XP.
Installing drivers for the Arduino Duemilanove, Nano, or Diecimila with Windows7, Vista, or XP:
When you connect the board, Windows should initiate the driver installation process (if you haven't used
the computer with an Arduino board before).
On Windows Vista, the driver should be automatically downloaded and installed. (Really, it works!)
On Windows XP, the Add New Hardware wizard will open:
When asked Can Windows connect to Windows Update to search for software? select No, not this time.
Click next.
Select Install from a list or specified location (Advanced) and click next.
Make sure that Search for the best driver in these locations is checked; uncheck Search removable
media; check Include this location in the search and browse to the drivers/FTDI USB Drivers directory of
the Arduino distribution. (The latest version of the drivers can be found on the FTDI website.) Click next.
The wizard will search for the driver and then tell you that a "USB Serial Converter" was found. Click
finish.
The new hardware wizard will appear again. Go through the same steps and select the same options and
location to search. This time, a "USB Serial Port" will be found.
You can check that the drivers have been installed by opening the Windows Device Mananger (in the
Hardware tab of System control panel). Look for a "USB Serial Port" in the Ports section; that's the
Arduino board.
5 | Launch the Arduino application
Double-click the Arduino application.
6 | Open the blink example
Open the LED blink example sketch: File > Examples > 1.Basics > Blink.

www.nexusrobot.com Robot Kits manual
8
7 | Select your board
You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino.
For Duemilanove Arduino boards with an ATmega328 (check the text on the chip on the board), select
Arduino Duemilanove or Nano w/ ATmega328. Previously, Arduino boards came with an ATmega168;
for those, select Arduino Diecimila, Duemilanove, or Nano w/ ATmega168. (Details of the board menu
entries are available on the environment page.)
8 | Select your serial port
Select the serial device of the Arduino board from the Tools | Serial Port menu. This is likely to be COM3
or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can
disconnect your Arduino board and re-open the menu; the entry that disappears should be the Arduino
board. Reconnect the board and select that serial port.
9 | Upload the program
Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX
and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear

www.nexusrobot.com Robot Kits manual
9
in the status bar. (Note: If you have an Arduino Mini, NG, or other board, you'll need to physically present
the reset button on the board immediately before pressing the upload button.)
A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in
orange). If it does, congratulations! You've gotten Arduino up-and-running.
If you have problems, please see the troubleshooting suggestions.
You might also want to look at:
the examples for using various sensors and actuators
the reference for the Arduino language
The text of the Arduino getting started guide is licensed under a Creative Commons
Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain.
See: http://arduino.cc/en/Guide/Windows
¾Language Reference
Arduino programs can be divided in three main parts: structure, values (variables and constants), and
functions.If you want to understand more, please See: http://www.arduino.cc/en/Reference/HomePage
¾Programming structure
This section describes the two important structures in the basic Arduino: setup () and loop ().They are
indispensable.
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using
libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board.
After creating a setup() function, which initializes and sets the initial values, the loop() function does
precisely what its name suggests, and loops consecutively, allowing your program to change and
respond. Use it to actively control the Arduino board.
Sample code
int buttonPin = 3;
// setup initializes serial and the button pin
void setup()
{
beginSerial(9600);
pinMode(buttonPin, INPUT);
}
// loop checks the button pin each time,
// and will send serial if it is pressed
void loop()

www.nexusrobot.com Robot Kits manual
10
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialWrite('L');
delay(1000);
}
¾Re-write Arduino bootloader
If you couldn't load the bootloader via the Arduino IDE with the parallel programmer from the Arduino
website. Then you can used the following method to Re-write the bootloader on your chip.
¾FT232RL BitBang Mode AVR-Writer
FT232RL is an USB-Serial bridge on an Arduino Dicimila/NG/Duemilanove PCB. It has the function to
manipulate each signal pin directly. It's called BitBang Mode.
If we use "avrdude-serjtag" we can burn the bootloader by Diecimila itself.
This section describe the method on Windows-XP.
Attention!!!
If you want use "avrdude-serjtag" on Linux or Mac OS, you must remake ( patch, reconfigure and
recompile) it.
There are useful projects. avrdude by FT245R/FT232R(Linux) and BitBang Mode AVR-Writer on
Mac (Translated to English by Google.) These projects made a way to BitBang Mode AVR-Writer on
Linux and Mac !!!
Of course, if you use Windows in Vmware on your Linux or Mac OS, you can run
"avrdude-serjtag(windows version)".
¾Modify the Diecimila
There are four pads written as X3 near FT232RL on a Diecimila PCB. (These pads are connected to the
control pins of FT232RL.).Remove the solder of these pads and insert a pin-header. And soldering
it.Connect the pins of X3 and the pins of ICSP by wires. Please see the photograph below. (click to
enlarge)

www.nexusrobot.com Robot Kits manual
11
¾Downloading
To downloading the "avrdude-serjtag" FTDI BitBang AVR-Writer from the internet.
configure-file for avrdude-serjtag
avrdude.conf (Update: included chip-parameter of ATmega328P and 88P)
avrdude-GUI-1.0.5.zip mirror site
avrdude-GUI-1.0.5.zip original site
(http://yuki-lab.jp/hw/avrdude-GUI/index.html)avrdude-GUI-1.0.5.zip mirror site
avrdude-GUI (yuki-lab.jp Version) require Microsoft .NET Framework 2.0. When .NET Framework 2.0 is
not installed. Download it from here (Microsoft .NET Framework 2.0 download page) and install it.
¾Installing
avrdude-serjtag
Exract serjtag-***.zip.
Copy "avrdude-serjtag" folder into the "C:\Program Files" folder.
Delete "src" folder in the "avrdude-serjtag" folder.

www.nexusrobot.com Robot Kits manual
12
avrdude.conf
Copy(overwrite) "avrdude.conf" into the "C:\Program Files\avrdude-serjtag\binary" folder.
This modified "avrdude.conf" has setting-scripts of "FTDI BitBang AVR-Writer" for Diecimila below.
#arduino diecimila
Programmer
id="diecimila";
desc = "FT232R Synchronous BitBang";
type = ft245r;
miso = 3; # CTS X3(1)
sck = 5; # DSR X3(2)
mosi = 6; # DCD X3(3)
reset = 7; # RI X3(4)
;
avrdude-GUI (yuki-lab.jp Version)
Extract avrdude-GUI-1.0.5.zip.
Copy "avrdude-GUI-1.0.5" folder into "C:\Program Files" folder.
avrdude-GUI (yuki-lab.jp Version) require Microsoft .NET Framework 2.0.
When .NET Framework 2.0 is not installed. Download it from here and install it.
¾Setting
Open the "C:\Program Files\avrdude-GUI-1.0.5" folder. And double click the "avrdude-GUI.exe" to run
it."avrdude-GUI" settings is as below from ①to ⑧.

www.nexusrobot.com Robot Kits manual
13
If your chip isn’t the same ,Some of the blank’s setting is different .change it base on the following chips :
¾Testing and confirming
- Disconnect a USB cable from Diecimila.
- Remove the wires of ICSP and X3.
- Connect a USB cable to Diecimila.
- Push the reset button of Diecimila.
- Start Arduino-IDE.
- Upload sample sketch “Blink”.
- And it will be run
See: http://www.roboticfan.com/article/html/797.shtml
or http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html
¾Adjust PWM frequencies
The ATmega328P has three timers known as Timer 0, Timer 1, and Timer 2. Each timer has two output
compare registers that control the PWM width for the timer's two outputs: when the timer reaches the
compare register value, the corresponding output is toggled. The two outputs for each timer will normally
have the same frequency, but can have different duty cycles (depending on the respective output
compare register).
By macegr in this forum post
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559/12
Pins 5 and 6: controlled by timer 0
Setting Divisor Frequency
0x01 1 62500

www.nexusrobot.com Robot Kits manual
14
0x02 8 7812.5
0x03 64 976.5625
0x04 256 244.140625
0x05 1024 61.03515625
TCCR0B = TCCR0B & 0b11111000 | <setting>;
Pins 9 and 10: controlled by timer 1
Setting Divisor Frequency
0x01 1 31250
0x02 8 3906.25
0x03 64 488.28125
0x04 256 122.0703125
0x05 1024 30.517578125
TCCR1B = TCCR1B & 0b11111000 | <setting>;
Pins 11 and 3: controlled by timer 2
Setting Divisor Frequency
0x01 1 31250
0x02 8 3906.25
0x03 32 976.5625
0x04 64 488.28125
0x05 128 244.140625
0x06 256 122.0703125
0x07 1024 30.517578125
TCCR2B = TCCR2B & 0b11111000 | <setting>;
All frequencies are in Hz and assume a 16000000 Hz system clock.
From koyaanisqatsi in this forum post
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559/12
If you change TCCR0B, it affects millis() and delay(). They will count time faster or slower than normal if
you change the TCCR0B settings. Below is the adjustment factor to maintain consistent behavior of
these functions:
Default: delay(1000) or 1000 millis() ~ 1 second
0x01: delay(64000) or 64000 millis() ~ 1 second
0x02: delay(8000) or 8000 millis() ~ 1 second
0x03: is the default
0x04: delay(250) or 250 millis() ~ 1 second

www.nexusrobot.com Robot Kits manual
15
0x05: delay(62) or 62 millis() ~ 1 second
(Or 63 if you need to round up. The number is actually 62.5)
Also, the default settings for the other timers are:
TCCR1B: 0x03
TCCR2B: 0x04
There may be other side effects from changing TCCR0B. For example my project would not properly
run with TCCR0B set to 0x02 or 0x01. But it worked fine at 0x03 and higher.
¾Simple Examples in Arduino 328
These examples are designed to demonstrate how to use the modules with the Arduino. The Arduino's
hardware serial port is not used to connect to our modules, which keeps it available to the USB port. That
allows downloading new programs without having to continually disconnect/reconnect things. Most of
these examples use the LCD03 display module to show the results, but it is also possible to display the
results on the PC, as demonstrated in the CMPS03 example. All the modules which use the I2C bus
have 1k8 pull-up resistors to 5v. You only need one set of resistors, located near the Arduino, regardless
of however many I2C devices you have connected to it.
¾LED control
Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example
with no hardware attached, you could see LED blinks.This example shows the simplest thing you can do
with an Arduino to see physical output: it blinks an LED.
Sample code
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
voidsetup(){
// initialize the digital pin as an output.Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); //waitforasecond
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}

www.nexusrobot.com Robot Kits manual
16
Led control
¾Button module
The controller has 7 build-in buttons S1-S7. S1-S5 use analog input, S6, S7 use digital input.
To enable S6 and S7, please apply the jumpers indicated in the red circle. S6 uses Digital Pin2, S7 uses
Digital Pin3. Once these enable jumpers have been applied, Pin 2 and 3 will be occupied.
Sample code
int ledPin = 13;
int key_s6 = 2;
int val=0;
void setup()
{
pinMode(ledPin, OUTPUT); // Set Pin13 to output mode
pinMode(key_s6, INPUT); // Set Pin12 to output mode
}
void loop()
{
if(digitalRead(key_s6)==0) //
{
while(!digitalRead(key_s6));
val++;
}
if(val==1) {
digitalWrite(ledPin, HIGH); //
}
if(val==2)
{
val=0;
Table of contents
Popular Robotics manuals by other brands

NEX ROBOTICS
NEX ROBOTICS FIREBIRD V ATMEGA 2560 Hardware manual

HEBI Robotics
HEBI Robotics Edward Assembly instructions

bierkuhl
bierkuhl BOS Cleantec IR duct inspection robot Operation and maintenance manual

Epson
Epson ProSix S5 Series manual

ABB
ABB IRC5 Compact operating manual

SuperDroid Robots
SuperDroid Robots IG32 DB Assembly and operation