Your Guide to Arduino Programming

This is your first Guide to Arduino Programming.

Introduction

If you are interested in electronics—and especially in building your own toys, games, and gadgets—then this tutorial is for you. Although the Arduino is a nice tool for designers and artists, only software developers are able to unleash its full power. So, if you’ve already developed some software—preferably with C/C++ or Java—then you’ll get of this tutorial. Below are all kinds of Arduino Board.

Parts List:

Many online shops sell Arduino components and electronic parts. Some of the best are Makershed, Sparkfun, and Adafruit. They have awesome starter packs, and I strongly recommend buying one of these. The best and cheapest solution is to buy the Arduino Projects Pack from Makershed (product code MSAPK). It contains nearly all the parts you need to build the tutorial’s examples, as well as many more useful parts that you can use for your own side projects. If you buy the Arduino Projects Pack, you’ll need to buy these additional parts separately:

  • Parallax PING))) sensor
  • TMP36 temperature sensor from Analog Devices
  • ADXL335 accelerometer breakout board
  • 6 pin 0.1″ standard header
  • Nintendo Nunchuk controller
  • A Passive Infrared Sensor
  • An infrared LED
  • An infrared receiver
  • An Ethernet shield
Complete Parts List:

If you prefer to buy parts piece by piece,rather than a starter pack, here is a list of all the parts. Suggested websites where you can buy the parts are listed here for your convenience, but many of these parts are available elsewhere also, so feel free to shop around.
* Good shops for buying individual components parts are RadioShack, Digi-Key, sparkfun, adafruit, and Mouser.

    • Arduino board such as: Uno, Duemilanove, or Diecimila
    • A standard A-B USB cable for USB 1.1 or 2.0
    • A half-size breadboard
    • Three LEDs —
    • 100 resistor, 10k, and 1kohms.

*It’s also not too useful to buy single resistors; buy a value pack.

    • Two pushbuttons.
    • Some wires, preferably breadboard jumper wires.
    • A Parallax PING))) sensor
    • A Passive Infrared Sensor
    • A TMP36 temperature sensor.
    • An ADXL335 accelerometer breakout board.
    • A 6 pin 0.1″ standard header.
    • An Arduino Ethernet shield.
    • An infrared sensor such as the PNA4602.
    • An infrared LED.
    • A 5V servo motor such as the Hitec HS-322HD.
    • Standard servos with an operating voltage of 4.8V–6V.
* For some of the exercises, you’ll need some optional parts:
    • An Arduino Proto Shield
    • Tiny breadboard
    • A piezo speaker or buzzer.
    • A tilt sensor.
* For the soldering tutorial, you need the following things:
    • A 25W–40W soldering iron
    • Standard 60/40 solder (rosin-core)
    • A sponge.

* You can find these things in every electronics store, and many have soldering kits for beginners that contain some useful additional tools. Take a look at Adafruit or Sparkfun

Exploring Arduino Board

arduino_uno_components

Installing Arduino IDE

To make it as easy as possible to get started with the Arduino, the Arduino developers have created a simple but useful integrated development environment (IDE). It runs on many different operating systems. Before you can create your first projects, you have to install it.

To Download the software click the link, and follow all the steps given. https://www.arduino.cc. You need to choose what OS are you using., Mac, Windows, or Linux. Don’t forget to install the driver for the IDE if needed. Also, please donate to arduino.cc if possible it helps the open source community to move forward.

In our first little project, we’ll make the Arduino’s status LED blink. The status LED is connected to digital IO pin 13. Digital pins act as a kind of switch and can be in one of two states: HIGH or LOW. If set to HIGH, the output pin is set to 5 volts, causing a current to flow through the LED, so it lights up. If it’s set back to LOW, the current flow stops, and the LED turns off. You do not need to know exactly how electricity works at the moment,

After the installation, connect your Arduino Board to your computer. Open the IDE, and enter the following code in the editor:

/*
Blink
Turn on the LED on for one second, then off for one second, repeateadly.
This example code is  in the public dumain of arduino.

void setup() {
//initialize the digital pin as an output
//Pin 13 has an LED connected on most arduino board:
  pinMode(13, OUTPUT);
}

void loop() {

digitalWrite[13,HIGH];//set led on
delay(1000);//wait second
digitalWrite[13,LOW ];//set led off
delay(1000)

}

Now, Here is the Example of more LED Blink:

multi led

Sensing the world around Us

Sensors make up an important part of physical computing, and the Arduino makes using various sensor types a breeze. Here, we will use both digital and analog sensors to capture some real-world state, and all we need is a couple of wires and some small programs.

ping_bb sensor

 

Below is the code for the above Project:

const unsigned int PING_SENSOR_IO_PIN =7;
const unsigned int BAUD)RATE = 9600;

void setup () {

    Serial.begin(BAUD_RATE);
}

void loop() {
   pinMode(PING_SENSOR_IO_PIN, OUTPUT);
   digitalWrite(PING_SENSOR_IO_PIN, LOW);
delayMicroseconds(2);

digitalWrite(PING_SENSOR_IO_PIN, HIGH);
delayMicroseconds(5);
  digitalWrite(PING_SENSOR_IO_PIN, LOW);


pinMode(PING_SENSOR_IO_PIN, INPUT);
  const unsigned long duration = pulseIn(PING_SENSOR_IO_PIN, HIGH);
if (duration == 0) {
  Serial.PrintIn("warning: We did not get a pulse from sensor...");

} else {

Serial.print("Distance to nearest object:..");
Serial.print(microseconds_to_cm(duration));
Serial.PrintIn(" cm");

}

delay(100);
}

unsigned long microseconds_to_cm(const unsigned long microseconds) {
return microseconds /29/2;

}