FOR ARDUINO
---------------------------------------------------------------------------------------------------------------------
Note: This tutorial is for novice user. It shows how to work on Arduino UNO board and explain
the working on open source Arduino software. Please refer to the documentation procedure
described here as followed. To work with this its mandatory that user already has an Arduino
UNO board.
---------------------------------------------------------------------------------------------------------------------
1.1. Overview
Arduino is a tool for making computers that can sense and control more of the physical
world than your desktop computer. It's an open-source physical computing platform
based on a simple microcontroller board, and a development environment for writing
software for the board.
It has a Separate Software Development Environment, which is also an integrated
development environment (IDE). Arduino is an open source means you are free to
modify the hardware or software of the Arduino boards according to the requirements.
For software, you can add AVR-C library and start writing code as in AVR studio.
Arduino consist of digital and analog I/O pins that can be interfaced to various extension
boards and other circuits. The boards feature serial communications interfaces, including
USB on some models, for loading programs from personal computers. The Arduino IDE
uses a simplified version of C++, making it easier to learn to program. Finally, Arduino
provides a standard form factor that breaks out the functions of the micro-controller into a
more accessible package. Arduino can interact with buttons, LEDs, motors, speakers,
GPS units, cameras, the internet, and even your smart-phone or your TV.
The Arduino will be seen by the computer as a standard serial interface. There is serial
communication APIs on most programming languages so interfacing Arduino with a
software program running on the computer should be pretty straight forward. The
Arduino board is a microcontroller board, which is a small circuit that contains a whole
computer on a small chip (the microcontroller).
Arduino can be used to develop interactive objects, taking inputs from a variety of
switches or sensors, and controlling a variety of lights, motors, and other physical
outputs. Arduino projects can be stand-alone, or they can communicate with software
running on your computer (e.g. Flash, Processing, MaxMSP).
Power- The Arduino Uno can be powered via the USB connection or with
an external power supply. The power source is selected automatically. The adapter
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or
battery can be connected by plugging a 2.1mm centre-positive plug into the board's
power jack. Leads from a battery can be inserted in the Gnd and VIN pin headers of
the POWER connector. The board can operate on an external supply of 6 to 20 volts. If
supplied with less than 7V, however, the 5V pin may supply less than five volts and
the board may be unstable. If using more than 12V, the voltage regulator may overheat
and damage the board. The recommended range is 7 to 12 volts.
Vin- The input voltage to the Arduino 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- The regulated power supply used to power the microcontroller and other
components on the board. This can come either from VIN via an on-board regulator, or
be supplied by USB or another regulated 5V supply.
3V3- A 3.3 volt supply generated by the on-board regulator. Maximum current draw is
50 mA.
Input and output- Each of the 14 digital pins on the Uno 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 ATmega8U2
USB-to-TTL Serial chip
PWM: 3, 5, 6, 9, 10, and 11- Provide 8-bit PWM output with the
analogWrite() function.
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.
Analog i/o port: The Uno has 6 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 the analogReference ()function. Additionally, some
pins have specialized functionality.
AREF: Reference voltage for the analog inputs. Used with analogReference ()
.
Reset- Bring this line LOW to reset the microcontroller. Typically used to
add a reset button to shields which block the one on the board.
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). A software serial library allows for
serial communication on any of the Uno's digital pins. The ATmega328 also support I2C
(TWI) and SPI communication. The Arduino software includes a Wire library to
simplify use of the I2C bus. To use the SPI communication please sees the ATmega328
datasheet.
Void setup()
Void loop()
Write down the above code to your Arduino Text Editor. See Screen shot of the same
below.
Step 1: Connect one end of your USB Cable with Computers USB Port and connect
other end with the Arduino board.
ARDUINO PROGRAM
Program for led blinking using Arduino Uno.
ARDUINO PROGRAM
Program for Led control using tactile switch.
int K0State = 0;
int K1State = 0;
int K2State = 0;
int K3State = 0;
void setup()
{
pinMode(K0, INPUT);
pinMode(K1, INPUT);
pinMode(K2, INPUT);
pinMode(K3, INPUT);
pinMode(L0, OUTPUT);
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
}
void loop()
{
ROBOMART ARDUINO QUICK LEARNING KIT MANUAL Page 19
K0State = digitalRead(K0);
K1State = digitalRead(K1);
K2State = digitalRead(K2);
K3State = digitalRead(K3);
if (K0State == HIGH)
{
digitalWrite(L0, HIGH);
}
if (K1State == HIGH)
{
digitalWrite(L1, HIGH);
}
if (K2State == HIGH)
{
digitalWrite(L2, HIGH);
}
if (K3State == HIGH)
{
digitalWrite(L3, HIGH);
}
else
PORTB=0b00000000;
}
ARDUINO PROGRAM
Program for controlling six leds by digital output pins.
void setup()
{
// put your setup code here, to run once:
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
digitalWrite(led4,LOW);
delay(200);
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
digitalWrite(led4,HIGH);
delay(200);
}
ARDUINO PROGRAM
Program for controlling six leds by digital output pins.
void setup ()
{
pinMode(carRed, OUTPUT);
pinMode(carYellow, OUTPUT);
pinMode(carGreen, OUTPUT);
pinMode(pedRed, OUTPUT);
pinMode(pedGreen, OUTPUT);
pinMode(button, INPUT);
void loop()
{
/* check if button is pressed
and it is over 5 sec since last button press*/
int state = digitalRead(button);
if(state==HIGH && (millis() - changeTime) > 5000)
{
changeLights(); //function to change lights
}
}
ARDUINO PROGRAM
Program for potentiometer to control the LED on PWM pin.
void setup()
{
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop()
{
// read the value from the potentiometer:
inputValue = analogRead(inputPin);
ARDUINO PROGRAM
void setup()
{
myservo.attach(5); // attaches the servo on pin 5 to the
servo object
Serial.begin(19200); // some servos doesn't work without
Serial
}
void loop()
{
val = analogRead(potpin); // reads the value
of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use
it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo
position according to the scaled value
delay(15); // waits for the
CIRCUIT DIAGRAM
ARDUINO PROGRAM
int redPotPin = 1;
int greenPotPin = 2;
int bluePotPin = 3;
#define COMMON_ANODE
void setup()
{
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
int redVal = analogRead(redPotPin) / 4;
int greenVal = analogRead(greenPotPin) / 4;
int blueVal = analogRead(bluePotPin) / 4;
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
ARDUINO PROGRAM
#include <LiquidCrystal.h>
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);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
Technical : +91-8744000666
Other Queries: +91-8744000555