Wednesday 3 January 2018

Arduino Lamp Controller

I developed an Android application its name is Arduino Lamp Controller by which you can control Lamps with Arduino and Bluetooth Device wirelessly.

Hardware Required


  1. Arduino Uno - 1Pcs.
  2. Android Phone or Tablet- 1pcs.
  3. Bluetooth Device Like HC-06 or HC-05- 1pcs.
  4. Jumper Wires- as per program.
  5. Led or Lamps - as per program.
  6. Resistors 220 ohms for Led.

Tuesday 9 May 2017

Arduino Basics

1. Arduino Testing

Here, We are going test the Arduino by using a program its name is "Arduino blinking". we are testing Arduino by blinking its L1 SMD led which is corresponding to pin 13.

Procedure

Just connect Arduino with your pc or laptop and upload following program.

Program

/* This program is to test the Arduino*/
const int led=13;

void setup()
{
  // put your setup code here, to run once:
  pinMode(led,OUTPUT); //declaring pin 13 as Output
}

void loop()
{
  // put your main code here, to run repeatedly:
  digitalWrite(led,HIGH); // led blink
  delay(1000); //make delay for one second
  // led off time
  digitalWrite(led,LOW); //led will got off
  delay(1000);  // delay for one second

}

Video



2. Arduino blinking an external LED

Here, I am going to blink an external led and practicing the function digitalWrite(). we reacquired one led has rating of 5V and 220 ohm resistance which is connecting to reduce the current flowing through the led. An arduino pin carry only 20 ma current.

Hardware Required

1. Arduino UNO ; 1pcs.
2. Jumper wire  : 2pcs.
3 Led : 1pcs
4 Resistance 220 ohm : 1pcs.

Image showing circuit diagram



Connect pin 13 to anode of led (Anode of led is the longest pin), connect 220 ohm resistance with cathode. one end of resistance connect to ground

Video


Program


/* This program is to blink an led with an Arduino*/
const int led=13;//led connect with this pin

void setup()
{
  // put your setup code here, to run once:
  pinMode(led,OUTPUT); //declaring pin 13 as Output
}

void loop()
{
  // put your main code here, to run repeatedly:
  digitalWrite(led,HIGH); // led blink
  delay(1000); //make delay for one second
  // led off time
  digitalWrite(led,LOW); //led will got off
  delay(1000);  // delay for one second

}






Wednesday 26 April 2017

Android meeting Arduino

Hardware required


  1. Arduino uno-1 pcs.
  2. Android phone or Tablet.
  3. Bluetooth adapter HC 06-1pcs.
  4. LEDs - 3 nos.
  5. Jumper wires - 7 nos.

HC06 Bluetooth Device

Project description


I am going to control 3 LEDs by using a mobile phone which is running in Android OS. Here, i am using android phone as remote to control led. I can switch on and switch off light and control the brightness of one led also. I made android app by MIT app inventor. You can download android app by searching "light" in MIT app inventor gallery after log on to this site or you can download by link https://drive.google.com/file/d/0B_w5O5-1CXjJU3hCcHoyempBREk/view?usp=sharing.

For installing this app, don't forget to enable phone to install app from Unknown sources. For this go to Settings~Security~Unknown sources and enable Allow installation of apps from unknown sources


Circuit Diagram


HC06 Connection 
Connect Vcc of HC06 to +5v of Arduino.
Connect Gnd of HC06 to Gnd of Arduino.
Connect Tx of HC06 to pin 10 of arduino.
Connect Rx of HC06 to pin 11 of arduino.


Video




Arduino Script


#include <SoftwareSerial.h>
SoftwareSerial Bt(10,11);//Rx of HC06 to 11 & Tx to 10
int val;
// recieving value as intiger from HC06 bluetooth device


void setup() 
{
 Bt.begin(9600);
 pinMode(7,OUTPUT);//pin 7,8 & 9 as output
 pinMode(8,OUTPUT);
 pinMode(9,OUTPUT);//pin 9 is also using as PWM output to //controll brightness
}

void loop() 
{
  if(Bt.available()>0)
  {
    val=Bt.read();
  }
  
  if(val>100)
  {
    switch(val)
    {
      case 101:
      {
        digitalWrite(7,1);
        break;
      }
      case 102:
      {
        digitalWrite(7,0);
        break;
      }
      case 103:
      {
        digitalWrite(8,1);
        break;
      }
      case 104:
      {
        digitalWrite(8,0);
        break;
      }
      case 105:
      {
        digitalWrite(9,1);
        break;
      }
      case 106:
      {
        digitalWrite(9,0);
        break;
      }
      case 107:
      {
        digitalWrite(7,1);
        digitalWrite(8,1);
        digitalWrite(9,1);
        break;
      }
      case 108:
      {
        digitalWrite(7,0);
        digitalWrite(8,0);
        digitalWrite(9,0);
        break;
      }
      
    }
  }
  else
  {
    //maping value to 0 to 255 from 0 to 255
    int mod_val=map(val,0,100,0,255);
    analogWrite(9,mod_val);
  }


}



Friday 7 April 2017

Arduino I2C communication and Light meter with Nokia 5110 and LDR

Hardware required

1. Arduino UNO  - 2pcs.
2. Nokia 5110 LCD display  - 1pcs.
3. LDR  - 1pcs.
4. Resistor 10 Kohm - 6pcs.
5. Resistor 1 Kohm  -1 pcs.
6 Jumper wires - 15 pcs.
7.Breadboard  -1pcs.

Project description

In this project, I am going to make one Light meter by using light depended resistor (LDR) and showing Arduino to Arduino I2C communication through wire library. For light measurement display, I am using Nokia 5110 LCD display and library is using for that one is pcd8544 library, you can download it from internet by searching in google.

Connection Diagram





Program

1. Program for Master Arduino.



// Wire Master Writer

#include <Wire.h>
float light;
int x;

void setup() 
{
  Wire.begin();
  Serial.begin(9600);
  // join i2c bus (address optional for master)
}


void loop() 
{
// connect LDR to analog A0 input by using 10 k ohm resistance as pull up resistor as shown in
// connection digram.
  light=analogRead(A0);
  x=map(light,0,1024,0,255);
  Serial.println(x);
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write("light intensity");        // sends five bytes
  Wire.write(x);              // sends one byte
  Wire.endTransmission();    // stop transmitting
  
  delay(500);
}

2. Program for Slave Arduino.


// Wire Slave Receiver

#include <Wire.h>
// Using wire library it is inbuilt in arduino IDE

#include <PCD8544.h>
// Library for nokia 5110 display. download it from internet

// Nokia 5110 lcd connection
// Nokia 5110 lcd is working wit 3.3 VDC so need to reduce +5v of arduino to 3.3V
// connect 10 k ohm resistance with every connection except vcc, Gnd and BL
// RST connect to 10 k-Ohm resistance series and pin no 6 of Arduino
// CE connect to 10 k-Ohm resistance series and pin no 7 of Arduino
// DC connect to 10 k-Ohm resistance series and pin no 5 of arduino
// Din connect to 10 k-Ohm resistance series and  pin no 4 of arduino
// Clk connect to 10 k-Ohm resistance series and pin no 3 of arduino
// Vcc to +5v of arduino directly
// BL connect with 1k ohm  to arduino pin +5v
// Gnd to Gnd of arduino



static const byte glyph[] = { B00010000, B00110100, B00110000, B00110100, B00010000 };
int x;

static PCD8544 lcd;

void setup()
{  
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600); // start serial for output
  lcd.begin(84, 48);
}

void loop() 
{
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print("Light in % ");
  lcd.setCursor(0,1);
  lcd.print("    ");
  lcd.setCursor(0,2);
  lcd.print("     "+String(x)+"%");
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()

void receiveEvent(int howMany) 
{
  while (1 < Wire.available()) 
  { 
    // loop through all but the last
    char c = Wire.read(); // receive byte as a character
   }

   x = Wire.read(); // receive byte as an integer
   x=map(x,0,255,0,100); //mapping for getting percentage

}

Video






Friday 31 March 2017

Arduino uno+Nokia 5110 lcd display+DHT22 Humidity and Temperature sensor


 Hardware required 

  1. Arduino uno.
  2. Nokia 5110 lcd display.
  3. DHT22 Humidity sensor.
  4. 10 k ohm resistor-6 nos
  5. 1 k ohm resistor- 1 nos.
  6.  Jumper wires(male to male)-10 nos.
  7. Breadboard-1pcs.

Project Description

this post is aims to sense and display Humidity and Temperature by using Arduino uno, Nokia 5110 LCD display and DHT22 Humidity sensor. These Hardwares are available in online markets like ebay,amazon and Ali Express.

Following video showing this project



PROGRAM


//To get DHT22 library go to menu option of IDE Sketch~Include library~Manage libraries and then //search like DHT sensor library. Then download DHT sensor library to your IDE.
//To get  nokia lcd 5110 library download PCD8544 lcd library same lake above.

#include <PCD8544.h>

#include "DHT.h"

#define DHTPIN 8
// Connect pin 2 of the sensor to arduino pin 8

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

// DHT22 connection
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to arduino pin 8
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor


// Nokia 5110 lcd connection
// Nokia 5110 lcd is working wit 3.3 VDC so need to reduce +5v of arduino to 3.3V
// connect 10 k ohm resistance with every connection except vcc, Gnd and BL
// RST connect to 10 k-Ohm resistance series and pin no 6 of Arduino
// CE connect to 10 k-Ohm resistance series and pin no 7 of Arduino
// DC connect to 10 k-Ohm resistance series and pin no 5 of arduino
// Din connect to 10 k-Ohm resistance series and  pin no 4 of arduino
// Clk connect to 10 k-Ohm resistance series and pin no 3 of arduino
// Vcc to +5v of arduino directly
// BL connect with 1k ohm  to arduino pin +5v
// Gnd to Gnd of arduino

static const byte glyph[] = { B00010000, B00110100, B00110000, B00110100, B00010000 };
static PCD8544 lcd;

void setup()
{
  lcd.begin(84, 48);
  lcd.createChar(0, glyph);
  
  dht.begin();

  Serial.begin(96000);
}
void loop() 
{
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();

    if (isnan(h) || isnan(t))
    {
      //if reading failed return to beginning of loop
      Serial.println("Failed to read from DHT sensor!");
      return;
    }

    //writing to Nokia 5110 lcd

      lcd.setCursor(0, 0);
      lcd.print("Humidity");
      lcd.setCursor(0,1);
      lcd.print("     "+String(h)+"%");
      lcd.setCursor(0,2);
      lcd.print(" ");
      lcd.setCursor(0,3);
      lcd.print("Temperature");
      lcd.setCursor(0,4);
      lcd.print("     "+String(t)+" *C");
}

Connection diagram









dssdsdsdsddsdsdsdd