Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Friday, 4 April 2014

Intel Galileo

Galileo is a microcontroller board based on the Intel® Quark SoC X1000 Application Processor, a 32-bit Intel Pentium-class system on a chip. It’s the first board based on Intel® architecture designed to be hardware and software pin-compatible with Arduino shields designed for the Uno R3. Digital pins 0 to 13 (and the adjacent AREF and GND pins), Analog inputs 0 to 5, the power header, ICSP header, and the UART port pins (0 and 1), are all in the same locations as on the Arduino Uno R3. This is also known as the Arduino 1.0 pinout.
Galileo is designed to support shields that operate at either 3.3V or 5V. The core operating voltage of Galileo is 3.3V. However, a jumper on the board enables voltage translation to 5V at the I/O pins. This provides support for 5V Uno shields and is the default behavior. By switching the jumper position, the voltage translation can be disabled to provide 3.3V operation at the I/O pins.
Of course, the Galileo board is also software compatible with the Arduino Software Development Environment (IDE), which makes usability and introduction a snap. In addition to Arduino hardware and software compatibility, the Galileo board has several PC industry standard I/O ports and features to expand native usage and capabilities beyond the Arduino shield ecosystem. A full sized mini-PCI Express slot, 100Mb Ethernet port, Micro-SD slot, RS-232 serial port, USB Host port, USB Client port, and 8MByte NOR flash come standard on the board.

Intel Galileo

Click the below link to buy

http://www.adafruit.com/products/1637#Description

https://www.sparkfun.com/products/12720

Wednesday, 4 September 2013

Arduino BLUETOOTH Communication with PC

In this post ill show you how to connect arduino to your laptop via bluetooth connectivity. 
Bluetooth is a wireless device which helps in sending and receiving data wirelessly. It is good for short range communication, range within 10mts. There are many bluetooth module out there in the market, but i am goin to use AUBTM-20 its a cheap bluetooth module. 

Parts you will need

A bluetooth module 
An arduino
A laptop with bluetooth
Jumper wires
A led

Connection

The fig. shows the connection between the bluetooth module and arduino. 
RX pin from bluetooth module goes to the TX pin on arduino and vice versa. Since the data that is being transmitted from bluetooth module is being received by arduino, and vice versa. Therefore we always connect RX pin to TX pin. connect a led to pin 13 on arduino.


Level shifting
In some bluetooth module the data voltage is 3.3v and the data voltage on arduino is 5v, the 3.3v form TX pin of bluetooth to RX pin on arduino will not create any problem, but the 5v from TX pin of arduino to RX pin on bluetooth will burn the bluetooth chip. In order to protect this we need to shift the level of TX arduino pin to 3.3v. make this connection for TX arduino pin to make it work with the bluetooth.



Putty

PuTTY is a free and open-source terminal emulator, we will use it to connect to the serial port.Download putty on your laptop. AFTER  making all the connections and uploading the code to arduino, turn on the arduino and your laptop, from your laptop search for the bluetooth module and make the connection and note down the serial port for connetion.
open the putty software 


  • click on the serial button
  • change the port to the bluetooth connection port
  • click on open
now when to press "1" you can see the led glow and when you press "0" the led will turn off.

Make use of this tutorial to make a HOME AUTOMATION system.


CODE




Sunday, 1 September 2013

Arduino Ping Sensor

The PING)))™ Ultrasonic Distance Sensor is an all-in-one module for accurately measuring distances between itself and objects nearby. The effective range is from about 1 inch to 10 feet (2 centimeters to 3 meters). The PING))) sensor consumes only modest power, and is ideal for use in mobile robots, security systems, and any other application for detecting nearby objects, or measuring their distance from the sensor.
In operation, object detection or distance measurement is initiated by sending a short high frequency (40 kHz) tone from the PING))) module. The time it takes to detect the return echo represents the distance between the PING))) module and any objects in front of it. Using basic arithmetic, you can convert the amount of delay of the echo to inches or centimeters. The sound frequencies used in the sensor are in the ultrasonic range, and are beyond human hearing.
PING))) Sensor diagram, emitting and listening for ultrasonic echo

Code & Schematic 



Upload this code to arduino and open the serial monitor.
kindly change the "pingpin" to pin no. 7 

Friday, 30 August 2013

Arduino PIR sensor

In this simple project, we’ll build a motion-sensing alarm using a PIR (passive infrared) sensor and an Arduino microcontroller. This is a great way to learn the basics of using digital input (from the sensor) and output (in this case, to a noisy buzzer) on your Arduino.

This project requires just a few parts, and because you're using a solderless breadboard and pre-cut jumper wires, you won't need any tools at all — except your computer and USB cable to connect the Arduino.
Connect digital input/output (I/O) pin 2 on the Arduino to row 1 on the breadboard.Connect the 5V pin on the Arduino to row 2 on the breadboard, and connect a nearby ground (Gnd) pin to row 3.Find the Gnd (–), Vcc (+), and Out pins on the PIR sensor.Plug the PIR sensor into the breadboard so that its (–) pin connects to the Gnd row, its (+) pin connects to 5V, and its Out pin connects to digital pin 2. connect a 10k resistor between PIR output pin and vcc.



Plug the LED's anode (the longer leg) into digital pin 13 on the Arduino.Plug the LED's cathode (the shorter leg, and/or the leg on the flattened side of the LED base) into the adjacent ground (Gnd) pin on the Arduino.Connect the buzzer's red wire to the Arduino's digital pin 10.Connect the buzzer's black wire to the Arduino's Gnd pin (there's a spare one on the Power block of pins).NOTE: These two wires can be reversed, as the polarity of the buzzer doesn't matter.

Code

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);    
      if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

Upload the code to the arduino and test it.
Enjoy!!!!!!

iPhone Arduino Push Notification

This project will help you to hack your doorbell to send Push notification and an email with an attached picture when somebody’s at the door. It use the free PushingBox service to delegate all the programming part and make things easy.

How does it work

  • 1. When the doorbell is pushed, the Arduino sends an HTTP request to the PushingBox API.
  • 2. PushingBox launches the user's scenario and gets a picture from the web camera.
  • 3. PushingBox sends a Push notification to the user's phone and a mail message with the picture attached.

Notifying Doorbell with PushingBox



Notifying Doorbell with PushingBox
  • Open your doorbell.
  • Solder wires to the button's terminals.
  • Close the doorbell.

Notifying Doorbell with PushingBox
  • Plug the wires into the Arduino.
  • One wire on the 5v pin;
  • One wire on the 3rd input pin;
  • The 10K resistor between GND and the 3rd pin.

Notifying Doorbell with PushingBox
  • Test the connectivity with a simple Arduino program.

Notifying Doorbell with PushingBox
  • The hardware part is finished. Let's define the way you will be notified.
  • Go to http://www.pushingbox.com.
  • Login with your Google account.
  • Go to the My Services page.
  • Click on Add a service.

Notifying Doorbell with PushingBox
  • Click on the service by which you want be notified.
  • Use Prowl or Pushme.to for iPhone Push notification;
  • Notifry for Android Push notification;
  • Toasty for Windows Phone Push notification.
  • Enter the name of your new service and fill in the API that this application gave you when you installed it.
  • Click Submit.

Notifying Doorbell with PushingBox
  • Now, go to the My Scenarios page.
  • Create a scenario called "Somebody's at the door".
  • Click on Create scenario.
  • Click on Add an Action.

Notifying Doorbell with PushingBox          First, add an action using the Email Service.
  • Fill in the mail Subject and the Body.
  • The third field is optional and is for attaching a shot from your IP camera to the email. Fill in the URL (publicly reachable) of your web camera. The camera's output must be a picture less than 100KB in size.
  • Do the same with your Push notification service and click the Back button.

Notifying Doorbell with PushingBox
  • Your scenario is now created.
  • Click on "Test" to test the scenario.
  • You should receive a Push notification on your phone and an email.
  • Make a note of the "DeviceID" value of this scenario. You will paste it into the Arduino code.

Notifying Doorbell with PushingBox
  • Download the Arduino source code from the PushingBox API page and open it.
  • In the #define DEVID1 line, paste the DeviceID of your scenario. Make sure you enclose it in quotes as shown.
  • Compile the code and program your Arduino.
  • You're done! Test it

Arduino Stepper motor Control

Stepper motors fall somewhere in between a regular DC motor and a servo motor. They have the advantage that they can be positioned accurately, moved forward or backwards one 'step' at a time, but they can also rotate continuously.
The stepper motor has five leads, and we will be using both halves of the L293D this time. This means that there are a lot of connections to make on the breadboard.
The motor has a 5-way socket on the end. Push jumper wires into the sockets to allow the motor to be connected to the breadboard.
Note that the red lead of the Stepper motor is not connected to anything.
fritzing.jpg
The following sketch uses the Serial Monitor, so once the sketch is installed and running, open the Serial Monitor and enter a number of 'steps'. Try a value of about 500, this should cause the motor to turn through about 360 degrees. Enter -500 and it will turn back in the reverse direction.

Code

#include <Stepper.h>

int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;

Stepper motor(768, in1Pin, in2Pin, in3Pin, in4Pin);  

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);

  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);
  
  Serial.begin(9600);
  motor.setSpeed(20);
}

void loop()
{
  if (Serial.available())
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}

In this tutorial, we do not use the common Red connection. This connection is only provided if you are using a different type of drive circuit that does not allow the current in each coil to be reversed. Having a center connection to each coil means that you can either energise the left or right side of the coil, and get the effect of reversing the current flow without having to use a circuit that can reverse the current.
Since we are using a L293D that is very good at reversing the current, we do not need this common connection, we can supply current in either direction to the whole of each of the coils.

Arduino servo Control

The servo motor has three leads. The color of the leads varies between servo motors, but the red lead is always 5V and GND will either be black or brown. The other lead is the control lead and this is usually orange or yellow. This control lead is connected to digital pin 9.
The servo is conveniently terminated in a socket into which we can push jumper wires, to link it to the breadboard and then to the Arduino.
fritzing_sweep.jpg

If servo Misbehaves

Your servo may behave erratically, and you may find that this only happens when the Arduino is plugged into certain USB ports. This is because the servo draws quite a lot of power, especially as the motor is starting up, and this sudden high demand can be enough to drop the voltage on the Arduino board, so that it resets itself.
If this happens, then you can usually cure it by adding a high value capacitor (470uF or greater) between GND and 5V on the breadboard.
The capacitor acts as a reservoir of electricity for the motor to use, so that when it starts, it takes charge from the capacitor as well as the Arduino supply.
The longer lead of the capacitor is the positive lead and this should be connected to 5V. The negative lead is also often marked with a '-' symbol.
Load up the following sketch onto your Arduino. You should find that the servo immediately begins to turn first in one direction and then back in the other.
The sketch is based on the standard 'sweep' sketch that you can find in the Arduino Examples under the folder 'servo'.


#include <Servo.h> 

int servoPin = 9;
Servo servo;  
int angle = 0;   // servo position in degrees 
void setup() 
{ 
  servo.attach(servoPin); 
} 
 void loop() 
{ 
  // scan from 0 to 180 degrees
  for(angle = 0; angle < 180; angle++)  
  {                                  
    servo.write(angle);               
    delay(15);                   
  } 
  // now scan back from 180 to 0 degrees
  for(angle = 180; angle > 0; angle--)    
  {                                
    servo.write(angle);           
    delay(15);       
  } 
} 

Servo motors are controlled by a series of pulses and to make it easy to use them, an Arduino library has been created so that you can just instruct the servo to turn to a particular angle.

Arduino SERVO knob

You just need to add the pot and a lead from its slider to A0 on the Arduino

fritzing_knob.jpg


#include <Servo.h> 

int potPin = 0;  
int servoPin = 9;
Servo servo; 
 
void setup() 
{ 
  servo.attach(servoPin);  
} 
 
void loop() 
{ 
  int reading = analogRead(potPin);     // 0 to 1023
  int angle = reading / 6;              // 0 to 180-ish
  servo.write(angle);  
} 

There is now a second variable called 'potPin'.
To set the position of the servo, we take an analog reading from A0. This gives us a value of between 0 and 1023. Since the servo can only rotate through 180 degrees, we need to scale this down. Dividing it by six will give us an angle between 0 and 170, which will do just fine.

The position of the servo motor is set by the length of a pulse. The servo expects to receive a pulse roughly every 20 milliseconds. If that pulse is high for 1 millisecond, then the servo angle will be zero, if it is 1.5 milliseconds, then it will be at its centre position and if it is 2 milliseconds it will be at 180 degrees.The end points of the servo can vary and many servos only turn through about 170 degrees. You can also buy 'continuous' servos that can rotate through the full 360 degrees.

Monday, 19 August 2013

Digital Thermometer

This tutorial shows an interesting way to read the temperature from the environment with the Arduino, and shows it on a LCD 16x2 display (in Fahrenheit), by using some elements from its programming and the temperature LM35DZ sensor.
For that, it will be necessary the following components:
- 1 Arduino board
- 1 LCD 16x2 display
- 1 10K potentiometer
- 1 Temperature LM35 sensor
- Jumpers for connection
This sensor captures the external temperature and converts it into a corresponding voltage value. In this circuit, we connect the output Vo of the sensor to the Arduino’s A0 pin, which converts it to a float value of temperature, and then, exhibits it on the LCD. The 10K potentiometer adjusts the contrast of the display.

Now, set up the circuit below with the Arduino and the other components:  
And then, open the Arduino’s IDE and enter the following code:

#include  <LiquidCrystal.h>         // Include the library to use a LCD display
#define          sensor           0        // Define the A0 pin as “sensor”

int  Vin;           //  Variable to read the value from the Arduino’s pin
float  Temperature; //  Variable that receives the converted voltage value to temperature
float     TF;   // Variable to receive the converted value from  ºC to ºF

LiquidCrystal  lcd    (12, 11, 5, 4, 3, 2); 
/* The function above declares which Arduino’s pins will be used for controlling the LCD */
void  setup()
{
  lcd.begin(16, 2);                            //  It tells the Arduino that the display is a 16x2 type
  lcd.print("Temperature: ");           //  Send the text to the screen of the display.
}
void  loop()
{
  Vin = analogRead (sensor);  /*   Tells the Arduino to read the pin and stores the value in “Vin” */
  Temperature=(500*Vin)/1023;  /* Converts the voltage value into temperature and stores it into the “Temperature”  variable  (in  ºC)*/
TF = ((9*Temperature)/5)+32; // Converts  ºC to ºF
  lcd.setCursor(0, 1);           // Moves  the cursor of the display to the next line
  lcd.print(TF);    // Exhibits the value of the temperature on the display
  lcd.print(" F");         // Writes “F” to indicate that it is in Fahrenheit scale.

  delay(1000);  //  Waits for a second to read the pin again
}
In the end, upload the code to your Aduino.
Your project to show the temperature is ready!!! We hope you have enjoyed. Any doubts, post here.
Note: The LM35DZ sensor converts temperature values from -55ºC to 150ºC.
If somebody is interested, this is the explanation for the conversion calculation from voltage to temperature done by the software.
In this sensor, for each 1ºC received, the Vo output is added in 10mV, in a range from 0 to 5V, with 10 bits of resolution for Analog/Digital conversion (1024 different values to represent the temperature).
Thus, the maximum value (1023, therefore it is from 0 to 1023) will be 5V. The half will match 511 or 2.5V, and so forth. For calculation purposes, there would be 5V in the output of the sensor for a temaprature value of 500ºC (which is different in a real situation). However, this regard lets us generalize it to the following relation:
Temperature  ----- Vin
         500ºC  ----- 1023              (maximum values)

So, there will be:
Temperature = (500*Vin)/1023, but as it is in ºC and we want in ºF, we convert it:
TF = ((9*Temperature)/5)+32, and this is the printed value on the LCD display.

Saturday, 10 August 2013

Interfacing relay with Arduino

In this quick Arduino tutorial I will explain how you can control a relay using the Arduino Board, one 1K and one 10K resistors, 1 BC547 transistor, one 6V or 12V relay, one 1N4007 diode and a 12V fan. When the button is pressed the fan will turn ON and will remain in this state until the button is pressed again.

Schematic 

arduino control relay schematic

Working

When the button is pressed the Arduino board will put pin 2 in HIGH state, meaning 5V on pin 2. This voltage is used to drive the transistor that will switch ON the relay and the load (in our case the fan) will be powered from the main power supply.
You cannot use the 5V from the USB to power up the transistor and the LOAD because the USB port usually delivers only 100mA, and this is not enough to switch the relay and the LOAD. That is why you must use an external power supply (Vcc) that is between 7 to 12 volts to power up the Arduino board and the transistor + relay. The load uses its own power supply, for instance if you use a light bulb then you might connect it to the 110/220V mains or any other power source.

Code

int pinButton = 8;
int Relay = 2;
int stateRelay = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 500;

void setup() {
  pinMode(pinButton, INPUT);
  pinMode(Relay, OUTPUT);
}

void loop() {
  stateButton = digitalRead(pinButton);  
  if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
    if(stateRelay == HIGH){
      stateRelay = LOW; 
    } else {
       stateRelay = HIGH; 
    }
    time = millis();
  }
  digitalWrite(Relay, stateRelay);
  previous == stateButton;
}


#### DO NOT connect in any ways the main power supply that drive the LOAD to the arduino and transistor circuitry!  ######

Friday, 9 August 2013

Working with MOSFET

Introduction

MOSFET or simply FET (MOS = metal-oxide semiconductor and FET = field effect transistor) is a type of transistor, a component used as a switch or an amplifier of electric signals.


MOSFETs

A MOSFET usually has three terminals: Gate, Source and Drain. There are two essential types: N-channel and P-channel, which are basically different because of the polarization. The current to be supplied to the circuit, which will circulate between Source and Drain of the FET, is controlled by the voltage applied on the Gate terminal. This last one has a dielectric separation from the other two, generating therefore an almost-null current value on the Gate, and an electric field which influences in the Source and in the Drain. Below, we have these two basic types of FETs and their corresponding usual symbols:Concerning Polarization:                                                   P-Channel                       N-Channel Another more known type of transistor, the BJT (bipolar junction transistor),  also has three terminals: Base, Collector and Emitter. The current to be supplied to the circuit, which will circulate between Collector and Emitter of the BJT, is controlled by the current of the Base terminal, unlike a MOSFET, which is controlled by the voltage. This is one of the main differences between them, causing a TBJ to be generally applied in circuits with a low value of current, and a FET not only for these ones but also for applications with higher values of power/current.Application Examples of MOSFETsOne of the most common applications for MOSFETs is on CMOS circuits (see the reference link at the end of this tutorial for more details). However, there are also others, for example:- Voltage Controlled Resistance- Power Switching Circuits- Frequency Mixers- Etc. Example: Turning a DC motor on with a MOSFET (MOSFET as a switch) and the Arduino.Components:- 1 Arduino Board - 1 MOSFET Transistor (N-channel) - 1 MOSFET Transistor (P-channel)- 1 DC motor (5V - 1A)- Jumpers for Connection- 1 Resistor of 200 Ohms- 1 5V - 1A Source Hardware:

With a N-channel MOSFET:       
With a P-channel MOSFET:


// Controlling a DC motor with a MOSFET transistor (basic application) for P-channel and N-channel// The motor used in this Firmware is of 5V - 1A// This hardware was not projected to control the sense of rotation of the motor (unless it inverts its polarity), only its speed.// Nevertheless, it can be controlled by a more elaborated hardware (an H bridge of MOSFETs for example)


#define GatePin 6 // Defines the pin to receive the signal in the Gate of the MOS

int GateSignal = 0; // Value that will be set in the PWM pin (0 to 1023) for controlling the speed of motor.


void setup () 

{pinMode (GatePin, OUTPUT); // Defines Arduino's pin 5 as an output}

void loop () 
{ while ((GateSignal <0) || (GateSignal >1023)) 
{ continue; }
analogWrite (GatePin, GateSignal); // But if it is in this range, the Arduino sends the signal to the "GatePin".}



Pay attention to the blue line of the code. In N-channel MOS polarization, the maximum rotation of the motor will be when the value of "GateSignal" is 1023 (therefore in N-channel the Gate terminal conducts with logic level "1"). However in P-channel, this rotation will be the maximum if the logic level of "GateSignal" is "0" (therefore in P-channel the Gate terminal conducts with logic level "0"). And the same happens with the minimum rotation.