admin – RoboIndia https://mishu.in Mon, 22 Jul 2024 07:02:24 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://mishu.in/wp-content/uploads/2024/03/cropped-Robo-India-and-Roinco-Logo-32x32.png admin – RoboIndia https://mishu.in 32 32 All Category https://mishu.in/7110-2/ https://mishu.in/7110-2/#respond Sun, 21 Jul 2024 06:16:57 +0000 https://mishu.in/?p=7110 Category

]]>
https://mishu.in/7110-2/feed/ 0
Transistor and Relay with Arduino. https://mishu.in/arduino-transistor-relay/ https://mishu.in/arduino-transistor-relay/#respond Mon, 27 May 2019 10:22:08 +0000 https://mishu.in/arduino-transistor-relay/ This tutorial explains following concept, Transistor Switching, Working of Relay, Switching with relay on Arduino, Motor control on Arduino using Relay.

1. Introduction:

This tutorial explains following things-

  1. Switching with NPN transistor.
  2. Working and concept of Relay
  3. Switching by relay.
  4. Relay and Arduino
  5. Motor control by Relay on Arduino

1.2 Switching by NPN Transistor.

make the following circuit. When you give High signal on Input it connects the LED to GND. Here we are taking HIGH input by push button switch.

1.3 Relay:

Following Video of Robo India explains working and concept of relay-

To use Relay with micro controller we need Transistor also for switching.

1.3 46ND006-P:

This is the relay we are going to use. This relay has got two poles, means there are two switches but both are trigged by a single Coil thus they operate simultaneously. Following Diagram will give you better understanding about the relay we are using.

2. Required Hardware

Following Hardware will be required to perform the example of this tutorials.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 20
4.1 K Resistance6
55 Volt – 2 Pole relay.46ND006P1
6.NPN Transistor
1
7.Indicator LEDIn three different colors.5
8.Hobby DC Motor1

3. Building Circuit – 1 (Understanding of Relay)

This circuit is to make you understand the concept of relay. Our relay has got two poles, thus we have connected 4 LED to this. Two at Normally Connected pins and two are normally open pins. One status LED is also there. The Status LED tells that Relay is on of Off. If Status LED is on it means that relay is on (Common is connected to NC.) and vice versa.

Red LED- Statuts LED of Relay

Yellow LED – Connected to NC terminal of Relay

Green LED – Connected to NO terminal of Relay

Conclusion we can draw –

If red is off – means relay is off – means – Common terminals of Relay are connected to NC – Thus Yellow  LEDs are ON.

If red is ON – means relay is ON – means – Common terminals of Relay are connected to NO – Thus Green LEDs are ON.

Video will help you to understand.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

here is the schematic:

or

3.2 You may go with original Arduino UNO Board-

here is the schematic:

4. Programming:

We don\’t need any special programming to operate Relay of Transistor, Simple Digital output programming is required. So the programme we have added here is as same as in our other tutorial of Digital Output – LED Blinking. The same codding is used throughout the tutorial.

You may download code (Arduino Sketch) from here.

// Digital output tutorial by ROBO INDIA
// www.roboindia.com
// Digital output is taken on a LED that remains ON for one second and 
// OFF for another.

// Defining Pin 2 as LED.
const int LED = 2;  // from the circuit we can see that we have connected LED on Pin 2


void setup() {                
    pinMode(LED, OUTPUT); // Defining LED pin as OUTPUT Pin.   
}

// Below mentioned code runs for ever(infinite loop)
void loop() {
  digitalWrite(LED, HIGH); // LED gets turned ON (1/HIGH/+5V)
  delay(1000);             // Waiting for one second. 
  digitalWrite(LED, LOW);  // LED gets OFF (0/LOW/0V/GND)
  delay(1000);        // here and above Delay is in mili second (1000 = 1 second)
}

5. Circuit -2 (Motor control on Arduino using Relay):

As we have mentioned earlier that the codding is same for the entire tutorial. Here we are controlling one DC motor on Arduino board. Motor consumes more power than the other circuit thus you will need separate Power supply to run a motor. It will not run on Laptop/PC\’s USB.

The circuit you will need is here –

5.1. You may go with Robo India R-Board (Arduino UNO based)-

here is the schematic of above circuit:

5.2. or You may go with orginal Arduino Board –

here is the schematic of above circuit:

7. output:

Here is the output of this tutorial. Above code is implemented on Robo India R-Board and Arduino UNO Both.

If you have any query please write us at info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com


]]>
https://mishu.in/arduino-transistor-relay/feed/ 0
Motor Control Using transistor and Relay https://mishu.in/boe-relay/ https://mishu.in/boe-relay/#respond Fri, 24 May 2019 09:38:00 +0000 https://mishu.in/boe-relay/ This tutorial explains following concept, Transistor Switching, Working of Relay, Controlling motor using Transistor and Relay. This tutorial is based upon Robo India\’s Tutorial of Relay on Arduino. 

1. Introduction:

This tutorial is in the continuation of Transistor and Op Amp (LM358) comparator tutorial. Output of LM358 is used to trig Transistor to operate relay. Then relay is controlling Motor.

1.2  Working of Relay:

Following Video of Robo India explains working and concept of relay-

To use Relay with micro controller we need Transistor also for switching.

1.3 46ND006-P:

This is the relay we are going to use. This relay has got two poles, means there are two switches but both are trigged by a single Coil thus they operate simultaneously. Following Diagram will give you better understanding about the relay we are using.

2. Required Hardware

Following Hardware will be required to perform the example of this tutorials.

S.No.ItemQuantity
1.Robo India\’s Basics of Electronics Kit Platform
(Without transoformer)
1
2.9 Volt Battery with connector1
3.Male to male Jumpers 20
4.1 K Resistance2
 4.7 K Resistance2
55 Volt – 2 Pole relay.46ND006P1
6.NPN Transistor – 2N22221
7.Indicator LED1
8.Hobby DC Motor1
910K Pot1
10Op Amp LM3581
11Diode1

3. Circuit

This circuit is in the continuation of other tutorials of Robo India.Op Amp as comparator, Transistor. The motor will be controlled through 10K pot. As the voltage from Pot goes high than the voltage at Pin 3 of LM358 Motor gets off. It is to be noted that this Pot will not control speed of motor.

The relay is rated for 5V. Thus relay and Op Amp is supplied 5V through 7805 Voltage Regulator. And motor is connected to 9V through relay.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com



]]>
https://mishu.in/boe-relay/feed/ 0
Transistor as Switch https://mishu.in/transistor-as-switch/ https://mishu.in/transistor-as-switch/#respond Fri, 24 May 2019 08:58:52 +0000 https://mishu.in/transistor-as-switch/ Robo India in this tutorial explains how to use transistor as switch.

1. Introduction:

Transistor can be used for many operations eg. amplification, switching etc. Here in this tutorial transistor is being used a switch.

A transistor has got three terminals Collector, Base and Emitter. If Base is trigged with some voltage, It allows current to pass from collector to emitter. It supports upto 500ma current. This phenomena is used for switching.

Download Datasheet of 2N2222 Transistor. 

1.2 List of parts 

Following parts will be used to perform this circuit. 

S.No.ItemQuantity
1.Basics of Electronics Kit\’s Platform(Without Transformer)
1
2.9V Battery with connector
1
3.Indicator LED
1
4.1 K Resistance 
2
5.Jumper Wires male to male6
6.2N2222 Transistor1

2. Circuit

This circuit explains how to use transistor as a switch. Here as discussed above the base is being trigged by push button. If there is a circuit where input can be taken from IC or microcontroller then attach that input to base instead of Push button. Here in the circuit diagram 9V battery is used, You may use DC power supply with help of transformer. Click on image to zoom.

3. Resources:

Rectifier Circuit if you want you use transformer instead of battery.

Download Datasheet of P2N2222 Transistor.

Buy This Kit from Robo India Store

If you have any query please write us at info@roboindia.com

our whatsapp helpline:  +91 9694011188

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

]]>
https://mishu.in/transistor-as-switch/feed/ 0
Pushbutton Operation https://mishu.in/push-button/ https://mishu.in/push-button/#respond Fri, 24 May 2019 08:45:41 +0000 https://mishu.in/push-button/ Robo India in this tutorial explains how a push button works. This is used as an input device. That takes input from user. This is also termed as push to on switch. 

1. Introduction:

Push button is a switch which connects its terminal if it pressed. As the button is released terminal gets disconnected. Thus it is used to take input from user. This input can be high or low voltage that depend that one terminal is connected to which source.

The switch is to be there in a circuit in series mode

1.2 List of parts 

Following parts will be used to perform this circuit. 

S.No.ItemQuantity
1.Basics of Electronics Kit\’s Platform(Without Transformer)
1
2.9V Battery with connector
1
3.Indicator LED
1
4.2.2 K Resistance 
1
5.Jumper Wires male to male2
6.Pushbutton1

2. Circuit

The following circuit explains operations of Push button switch. Here in the circuit diagram 9V battery is used, You may use DC power supply with help of transformer. Click on image to zoom.

3. Resources:

Rectifier Circuit if you want you use transformer instead of battery.

Buy This Kit from Robo India Store– Buy here

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

]]>
https://mishu.in/push-button/feed/ 0
Arduino – Peizo Buzzer https://mishu.in/arduino-5v-peizo-buzzer/ https://mishu.in/arduino-5v-peizo-buzzer/#respond Thu, 23 May 2019 12:10:26 +0000 https://mishu.in/arduino-5v-peizo-buzzer/ This tutorial of Robo India is on Peizo Buzzer. Here two examples are included one plays beep sound and other one plays a song.

1. Introduction:

This tutorial of Robo India expalins how to use a Peizo Buzzer on Arduino. When voltages are supplied to its terminal it generates beep sound. This buzzer is used to give beep sound to various embedded systems.

2. Required Hardware

Following Hardware will be required to perform this sketch of shift register.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 5
4.100 OHM Resistance 
5.5 Volt Buzzer1

3. Building Circuit

Make following circuit with the help of above mentioned components. We have included two examples here both of them use the following circuit.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

Here is the schematic of this circuit-

or

3.2 You may go with original Arduino UNO Board-

Here is the schematic of this circuit-

4. Programming 1 – Playing a beep sound.

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section.

You may download this code (Arduino Sketch) from here.

/*
Beep sound generation Tutorial 
By Robo India
http://roboindia.com
*/


const int Buzzer = 9;

void setup() 
{
  pinMode(Buzzer, OUTPUT);
}

void loop() 
{
  digitalWrite(Buzzer, HIGH);
  delay(400);
  digitalWrite(Buzzer, LOW);
  delay(2000);
}

5. Programming 2 – Playing a song:

Cicruit is same as above mentioned. Copy this code and upload to your Arduino board.

You may download this code (Arduino Sketch) from here.

/*
Tone generation Tutorial 
By Robo India
http://roboindia.com
  note 	frequency
  c     262 Hz
  d     294 Hz
  e     330 Hz
  f     349 Hz
  g     392 Hz
  a     440 Hz
  b     494 Hz
  C     523 Hz
*/
  
const int Buzzer = 9;
const int songLength = 18;

char notes[] = "cdfda ag cdfdg gf "; // a space represents a rest
int beats[] = {1,1,1,1,1,1,4,4,2,1,1,1,1,1,1,4,4,2};
int tempo = 150;  // Speed of tempo

void setup() 
{
  pinMode(Buzzer, OUTPUT);
}

void loop() 
{
  int i, duration;
  
  for (i = 0; i < songLength; i++) // step through the song arrays
  {
    duration = beats[i] * tempo;  // length of note/rest in ms
    
    if (notes[i] == ' ')          // is this a rest? 
    {
      delay(duration);            // then pause for a moment
    }
    else                          // otherwise, play the note
    {
      tone(Buzzer, frequency(notes[i]), duration);
      delay(duration);            // wait for tone to finish
    }
    delay(tempo/10);              // brief pause between notes
  }
  
 
  while(true){}     // Remove this line if you want to play this song for ever.
}


int frequency(char note) 
{ 
  int i;
  const int numNotes = 8;      // number of notes we're storing
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};

  for (i = 0; i < numNotes; i++)   
  {
    if (names[i] == note)          
    {
      return(frequencies[i]);      
    }
  }
  return(0); 
}



6. Output:

Here is the output of the above two examples.

if you have any query please write us at: info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

]]>
https://mishu.in/arduino-5v-peizo-buzzer/feed/ 0
Arduino – IR Proximity and color detection sensor https://mishu.in/arduino-ir-proximity-color-detection-sensor/ https://mishu.in/arduino-ir-proximity-color-detection-sensor/#respond Thu, 23 May 2019 12:00:34 +0000 https://mishu.in/arduino-ir-proximity-color-detection-sensor/ This tutorial of Robo India explain the working concept of Infrared(IR) sensor for color detection and proximity. The constructed circuit is performed on Arduino platform.

1. Introduction:

A step by step illustrated tutorial to use IR Sensor on Arduino. This tutorial explains the concept and construction of IR Sensor for color detection and proximity measurement. This sensor comprises following two main parts (IR-LED and Photo Diode).

1.1 IR LED (Infrared Transmitter): It is as same as other LED we generally see, but it emits light of Infrared range 700 nanometers (nm) to 1 mm. This light is not visible through naked eyes but can be seen by camera (that is why these are also used in night vision camera). Following image shows how IR is seen on camera. In this image IR LED is ON.

In the following image IR LED is OFF(This is how it is seen by naked eyes). So camera is a good option to test whether IR LED is working or not.

1.2 Photo Diode: It gives response in term of change in resistance when light falls on it. That change we measure in terms of voltage.

1.3 IR Sensor as a proximity sensor:

IR LED (Transmitter) emits IR light, that light get reflected at the object, the reflected light is received by IR receiver (Photo Diode). Amount of reflection and reception as the distance varies. This difference causes to change in input voltage through IR input. We observe these values and use it out projects. This is our Proximity sensor. Following diagram explains this concept.

Application of this sensor can be an obstacle avoiding robot.

1.4 IR sensor as color detector.
Lets see above mentioned concept from a different angle. The amount of reflection light will also depend upon the color of surface from which it is being reflected. Black is said to be perfect absorber and white is to be said perfect reflector. The reflection will be different for different colors. Thus make it a color detector.

Application of this sensor can be a line follower, a micro mouse or a grid solver.

Following diagram will help you to understand the concept of IR sensor as a color detector.

2. Required Hardware

Following Hardware will be required to perform this sketch of shift register.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 5
4.100 OHM Resistance 10K OHM Resistance11
5.IR LED Photo Diode Pair1

3. Building Circuit

Make following circuit with the help of above mentioned components.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

Here is the schematic of this circuit-

or

3.2 You may go with original Arduino UNO Board-

Here is the schematic of this circuit-

4. Programming:

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section.

Programming is simple Analog input programming. Input is coming from Photo Diode to Pin A0. Upload the programme to Arduino board and observe change in value at serial port. These values are useful while making an application using this IR sensor.

You may download this code (Arduino Sketch) from here.

/*
Tutorial of Analog IR Sensor.
Prepared by Robo India.
www.roboindia.com
 */

int analog_ip = A0;   // select the input pin Photo Diode.
int inputVal = 0;     // to store photo diode input


void setup() {
  Serial.begin(9600);   // Setup Serial Communication.               
  Serial.print(\"ROBO INDIA\\nroboindia.com\\nTutorial on Analog IR Sensor.\\n\");  
}

void loop(){
    inputVal = analogRead(analog_ip); // Reading and storing analog input value.

        Serial.print(\"Input Value:\");
        Serial.print(inputVal);       // Printing Analog input value of Photo Diode.
        Serial.print(\"\\n\");           // moving to new line
        delay(500);                   // Waiting for a while.

  
  
}

5. output:

Here is the output of this tutorial-

6. Following Product of Robo India can be useful for this circuit:

This sensor of Robo India gives both Analog and digital output.

\"\"

If you have any query please write us at info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com



]]>
https://mishu.in/arduino-ir-proximity-color-detection-sensor/feed/ 0
Arduino – Shift Register (Serial In Parallel Out) https://mishu.in/arduino-shift-register-serial-in-parallel-out/ https://mishu.in/arduino-shift-register-serial-in-parallel-out/#respond Thu, 23 May 2019 11:44:45 +0000 https://mishu.in/arduino-shift-register-serial-in-parallel-out/ This tutorial of Robo India explains how to extend output pins of Arduino Board. It is major constrain of Arduion. But with the help of this tutorial you can increase output pins of Arduino Board.

1. Introduction:

A step by step illustrated tutorial to extend output pins of Arduino. This tutorial uses 74HC595N shift Register for Serial in and Parallel out.

This register IC takes 3 pin input and gives output at 8 Pins. Thus this extends 3 pins to 8 pins.

1.1 SN74HC595N Shift Register.

This is a popular shift register we are using in this tutorial. It requires a three pin interface from Arduino

  1. Data pin: Data is sent in serial mode.
  2. Clock Pin: A clock runs on this pin
  3. Latch Pin: This pin is used to toggle so that shift register shows 8 bit data on output.

Data sheet of SNHC595N can be downloaded from here:

Following is the pinout diagram of SN74HC595N shift Register:

2. Required Hardware

Following Hardware will be required to perform this sketch of shift register.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 24
4.Indicator LED8
5.100 OHM Resistance 
6.SN74HC595N Shift Register1

3. Building Circuit

Make following circuit with the help of above mentioned components.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

Here is the schematic of this circuit-

or

3.2 You may go with original Arduino UNO Board-

Here is the schematic of this circuit-

4. Programming:

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section. A few function to consider for this sketch.

4.1 shiftWrite(Pin, State): This function is same as digitalWrite function. It makes Pin HIGH/LOW. Usage is as same as the digitalWrite function.

4.2increament() : This function is designed for LED array on  shift register, LED starts glowing from LED 0 to LED 7 and as all gets ON these starts getting OFF from LED 7 to LED 0.

4.2 OneByOne(): This function is similar to above mention increment() function but the difference is that in this function only one LED glows at a time. So in this function LED starts glowing from LED 0 to LED 7 and in the reverse order too.

4.3. AllHigh(): This function makes all output pins HIGH.

4.4 AllLow(): This function makes all output pins LOW.

4.5 SOS(): This function repeats AllHigh() and AllLow() function 10 times with an interval of 100ms between two steps.

The output Video demonstrate all of the above mentioned function.

You may download this code (Arduino Sketch) from here.

// Robo India Tutorial on Shift Register SN74HC595N
//http://roboindia.com/


int DataPin = 2;  // Data Pin is connected to Pin No. 2
int ClockPin = 3; // Data Pin is connected to Pin No. 3
int LatchPin = 4; // Data Pin is connected to Pin No. 4

byte Data = 0;  // 8 Bit Data to be sent through DataPin

void setup()
{
  pinMode(DataPin, OUTPUT);   // All 3 pins are output
  pinMode(ClockPin, OUTPUT);  
  pinMode(LatchPin, OUTPUT);
}


void loop()
{
  
  increment(); // LEDs Increament start from 0 - 7   
  delay(2000);  
  SOS();        // All LEDs ON and OFF 10 times
  OneByOne();   // LEDs Glow one by one from 0 to 7
  delay(2000);
  

}

// Function defined below-

void shiftWrite(int Pin, boolean State) // Function is similar to digitalWrite 
{                                       // State-0/1 | Pin - Pin No.
  bitWrite(Data,Pin,State);             // Making Pin(Bit) 0 or 1
  shiftOut(DataPin, ClockPin, MSBFIRST, Data); // Data out at DataPin
  digitalWrite(LatchPin, HIGH);                // Latching Data
  digitalWrite(LatchPin, LOW);
}

void increament()   //LEDs increment start from 0 - 7 
{
  int PinNo = 0;
  int Delay = 100; 
  
  for(PinNo = 0; PinNo < 8; PinNo++)
  {
    shiftWrite(PinNo, HIGH);
    delay(Delay);                
  }
  for(PinNo = 7; PinNo >= 0; PinNo--)
  {
    shiftWrite(PinNo, LOW);
    delay(Delay);                
  }
}

void OneByOne()  // LEDs Glow one by one from 0 to 7
{
  int PinNo = 0;
  int Delay = 100; 
  
  for(PinNo = 0; PinNo < 8; PinNo++)
  {
    shiftWrite(PinNo, HIGH);
    delay(Delay); 
    shiftWrite(PinNo, LOW);    
  }
  for(PinNo = 7; PinNo >=0 ; PinNo--)
  {
    shiftWrite(PinNo, HIGH);
    delay(Delay); 
    shiftWrite(PinNo, LOW);    
  }

}

void AllHigh()   // sets all High
{
  int PinNo = 0;
  for(PinNo = 0; PinNo < 8; PinNo++)
  {
   shiftWrite(PinNo, HIGH);  
  }
}

void AllLow()   // Sets all low
{
  int PinNo = 0;
  for(PinNo = 0; PinNo < 8; PinNo++)
  {
   shiftWrite(PinNo, LOW);  
  }
}

void SOS(){                  // All LEDs ON and OFF 10 times
  for (int x=0; x<10; x++){    
  AllHigh();
  delay(100);
  AllLow();
  delay(100);
  }
}


5. output:

Here is the output of this tutorial-

6. Following Product of Robo India can be useful for this circuit:

If you use this LED array it will save jumpers and circuit will be hassle free.

If you have any query please write us at info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

]]>
https://mishu.in/arduino-shift-register-serial-in-parallel-out/feed/ 0
Arduino – LDR (Light-Dependent Resistor) https://mishu.in/arduino-ldr-light-dependent-resistor/ https://mishu.in/arduino-ldr-light-dependent-resistor/#respond Thu, 23 May 2019 11:24:58 +0000 https://mishu.in/arduino-ldr-light-dependent-resistor/ This tutorial explains concept and how to use LDR (Light Dependent Resistor) with Arduino. An example is included in which a LED is controlled on the basis of LDR.

1. Introduction:

A step by step illustrated tutorial to use LDR on Arduino.

This tutorial is made on Original Arduino UNO and Robo India’s R-Board(UNO compatible).

1.1 LDR:

A LDR (Light Dependent Resistor) or a photo resistor is a photo conductive sensor. It is a variable resistor and changes its resistance in a proportion to the light exposed to it. It’s resistance decreases with the intensity of light.

2. Required Hardware

Following Hardware will be required to perform this LDR circuit.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 7
4.Indicator LED1
5.100 OHM Resistance&10 K Resistance11
6.LDR1

3. Building Circuit

Make following circuit with the help of above mentioned components. Some key points to understand about the circuit-

LDR is connected to a 10 Resistance in series. +5 Voltage is applied to this arrangement. As the light intensity changes LDR value changes thus the voltage drop on LDR will change and we are going to measure that voltage change.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

Here is the schematic of this circuit-

or

3.2 You may go with original Arduino UNO Board-

Here is the schematic of this circuit-

4. Programming:

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section. A few point to consider for this sketch.

1. It reads LDR value and prints them on Serial monitor. Once you upload this programme to your Arduino board open serial monitor and observe how values are changing with the change of Light intensity.

2. The attached LED glows in analog mode according to the LDR Values.

3. There is a condition of threshold; The attached LED remains OFF for all the values below Threshold limit. You can set your own threshold limit. In this programme we have given 800 as threshold. You can set t threshold to any value between 0 and 1023.

You may download this code (Arduino Sketch) from here.

// Robo India's Tutorial on LDR.
// http://roboindia.com/


int LDR = A0;            // LDR input at A0 pin.
int LED = 3;             // LED is connected to PWM Pin 3.
int LDRReading = 0;      // to store input value of LDR
int lEDBrightness = 0;   // to store the value of LED Brightness
int threshold_val = 800; // Check your threshold and modify it.

void setup(){
  Serial.begin(9600);     // initializing serail communication.
  pinMode(LED, OUTPUT);   // Defining LED pin as output.
}

void loop(){
  LDRReading = analogRead(LDR);    // Reading LDR Input.
  Serial.println(LDRReading);      // Printing LDR input value.
  
  if (LDRReading >threshold_val){                   // Condition to make LED ON.
  lEDBrightness = map(LDRReading, 0, 1023, 0, 255); // Converting LDR to LED Brightness.
  analogWrite(LED, lEDBrightness); // Writing Brightness to LED.
  }
  else{
  analogWrite(LED, 0);             // If LDR is below threshold make LED OFF.
  }
    
  delay(300);                      // delay to make output readable on serial monitor. 
}

5. output:

Here is the output of this tutorial-

6. Serial Output:

This sketch gives LDR Readings at serial monitor. Here is the Screenshot of the serial output.

If you have any query please write us at info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

]]>
https://mishu.in/arduino-ldr-light-dependent-resistor/feed/ 0
Arduino – LM 35 Temperature Sensor https://mishu.in/arduino-lm35-temperature-sensor/ https://mishu.in/arduino-lm35-temperature-sensor/#respond Thu, 23 May 2019 10:46:36 +0000 https://mishu.in/arduino-lm35-temperature-sensor/ This tutorial explain to use LM 35 Temperature sensor on Arduino Platform. This tutorial has got two example both of the example reads temperature, one displays it on LCD where as other one displays at serial monitor.

1. Introduction:

This tutorial deals with LM 35 Temperature sensor. It has two examples both read temperature through LM 35 Temperature sensor, one display the temperature on LCD where as other examples displays at serial monitor.

1.2 LM 35 Temperature sensor

It is a 3 pin IC, Operated on 4 to 20 volt. It gives output in voltage according to the temperature. 10 mili volt per degree Celsius is the output format of this sensor.

1.3 Pinout of LM 35 Temperature Sensor

2. Required Hardware

Following Hardware will be required to perform this LED fade in and fade out circuit.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 24
4.16×2 LCD1
51K Potentiometer1
6.LM-35 Temperature Sensor1

3. Building Circuit – 1 (Displays Temperature on LCD)

To run these practical examples make following circuit with the help of above mentioned components.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

here is the schematic:

or

3.2 You may go with original Arduino UNO Board-

here is the schematic:

4. Programming – 1 (To display temperature on LCD):

Once we are done with circuit part, here is our programme to this circuit. All of the commands are explained in the comment section. Output video is attached at the last of this tutorial, This example will be clear after watching the video.

You may download code (Arduino Sketch) from here.

/*
Temerature on 16X2 LCD Tutorial by ROBO INDIA
LM 35 Temp. IC is used.
http://roboindia.com/
*/

#include <LiquidCrystal.h> //includes LCD library.


LiquidCrystal MyLCD(12, 11, 5, 4, 3, 2); // Defining LCD.
int temp_pin = A0;  // LM 35 is connected to A0 Pin.
float temp;         // Variable to store temperature value.

void setup() {
   MyLCD.begin(16, 2); // Initializing 16X2 LCD.
   MyLCD.home(); // Home location : 0,0 
   MyLCD.print(\"Robo India\"); // Print on LCD.
   MyLCD.setCursor(0, 1);
   MyLCD.print(\"LM 35 Tutorial\");
   delay(4000);  
}

void loop() {
  
  MyLCD.clear();     // Clearing LCD
  MyLCD.home();      // Cursor set to 0,0
  temp = ReadTemp(); // Reading Temperature. 
  MyLCD.print(\"Temperature is-\");
  MyLCD.setCursor(0,1);
  MyLCD.print(temp); // Printing Temperature of LCD.
  MyLCD.print(\" Deg. C.\");
  delay(1000);       // delay of 1 second.  
}

// Function to read temperature.
float ReadTemp(){
int ip_adc_val = 0;
float temp =0;
temp = (5.0 * analogRead(temp_pin) * 100.0) / 1024;
return temp;
}

5. Circuit -2 (Displays temperature on Serial Monitor):

You need to make following circuit to run this programme.

5.1. You may go with Robo India R-Board (Arduino UNO based)-

here is the schematic of above circuit:

5.2. or You may go with original Arduino Board –

here is the schematic of above circuit:

6. Programming – 2 (Displays temperature on Serial Monitor):

This is the programme for the above mentioned circuit -2. This sketch is written to read temperature from LM 35 Temperature sensor IC and to display the read temperature at serial monitor. After uploading this programme to the Arduino Board, you will need to start Serial Monitor to see the result. We have included Screen shot of output at serial monitor.

All of the commands used in this sketch is explained in comment section.

You may download this sketch from here.

/*
Temperature on serial monitor Tutorial by ROBO INDIA
LM 35 Temp. IC is used.
http://roboindia.com/
*/

int temp_pin = A0;  // LM 35 is connected to A0 Pin.
float temp;         // Variable to store temperature value.

void setup() {
   Serial.begin(9600); // Serial comm. starting.
   Serial.println(\"Robo India\"); 
   Serial.println(\"LM 35 Tutorial\");
   delay(2000);  
}

void loop() {
  
  temp = ReadTemp(); // Reading Temperature. 
  Serial.print(\"Temperature is-\");
  Serial.print(temp); // Printing Temperature on serial port
  Serial.print(\" degree celsius\\n\");
  delay(1000);       // delay of 1 second.  
}

// Function to read temperature.
float ReadTemp(){
int ip_adc_val = 0;
float temp =0;
temp = (5.0 * analogRead(temp_pin) * 100.0) / 1024;
return temp;
}

7. output:

Here is the output of this tutorial. Above code is implemented on Robo India R-Board and Arduino UNO Both.

8. Screenshot of Serial output:

Here is the screenshot of serial output. (For example -2 : Displays Temperature on serial Monitor) 

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com


]]>
https://mishu.in/arduino-lm35-temperature-sensor/feed/ 0