Input Devices





    Task of the week

    What I have did

    Individual assignment :

  • Have studied the input device Ldr.

  • Measure somthings : add a sensor to a microcontroller board that you have designed and read it.

  • Designed a board of ldr.

    Group assignment :

  • Have programmed the board to display the readings on the serial monitor.

  • Probe an input device's analog level and digital signals.

  • Have described the input sensor BH1750 used in my final project.

  • Programmed it with my final project board.

  • Included the design files.


    Week-9 : -

    This week is about Input devices. Input devices are the sensors that sense the analog values that are physical values in the surrounding, like light, sound, distance, temperature,...etc, and convert this into the digital signal. We can use this digital values to run different systems. Also, these digital values help us to keep data of the particular system. In Wednesday's lecture, Neil has given us the introduction of input devices and how they work. Next day our instructor Mr. Suhas and Miss. Arundhati has explain us about the goal of this week. In this week I have decided to think about the sensor which I will use in my final project.

    About LDR : -

Week1-1

  • LDR that is Light Dependent resistor or Light Decreasing resistance or photo-conductive cell is a passive component that decreases the resistance with respect to receiving light(luminosity) on it's sensitive surface.

  • In the other word it operats on the principle of Photoconductivity. Photocunductivity is the optical and electrical phenomenon in which the electrical conductivity of the material increases due to absorption of electromagnetic radiations such as visible light, ultraviolet light, infrared light, or gamma radiation. Photoresistor or LDR is used in the light sensitive detector circuits, light- activated and dark-activated switching circuits, where it acts as a resistance semiconductor. In the dark photoresistor have the maximum resistance as several megaohms(MOhm) and in the light it has the resistance as low as few hundred ohm.

    Using LDR as a switch on breadboard : -

    In this week I have used LDR as a input device. Because my project is Solar automatice shredder which is base on the available light intencity of sun. The my project I am going the motor is get operate on the bases of available sulight. To get the clearity in this idea I have built up a simple cicuit of LED ON/OFF with the Ldr readings on breadboard with Arduino board. for that I have refer this document.

Week1-1

    Components used in the circuit : -

  • Arduino UNO

  • Photo resistor i.e. Ldr

  • Resistor of 10k ohm

  • Resistor of 221 ohm

  • LED

    Here in the circuit on the Breadboard where various components are mounted is acts as a PCB board on which we mount different components while desiging the circuit board on SRM-20, and the Arduino UNO used is acts as a Micro-controller.

    Code used for the LED blinking with Ldr : -

  • For opertaing the circuit I have used the following code. When we are using this code for programming the bread-board with components and arduino as a microcontroller then select : -
    Board : - "Arduino/Genuino Uno"
    and
    Programmer : - "ArduinoISP"
    from the tool menu of arduino IDE as shown below.

Week1-1


	

                
 
//modified by : Tejswini Chaudhari
// ON/OFF LED by LDR readings.
 
 
 
 int ldr=A0;//Set A0(Analog Input) for LDR.
 int value=0;
 void setup() 
 {
 Serial.begin(9600);
 pinMode(3,OUTPUT);
 }

 void loop() 
 {
 value=analogRead(ldr);//Reads the Value of LDR(light).
 Serial.println("LDR value is :");//Prints the value of LDR to Serial Monitor.
 Serial.println(value);
 if(value<300)
 {
  digitalWrite(3,HIGH);//Makes the LED glow in Dark.
 }
 else
 {
 digitalWrite(3,LOW);//Turns the LED OFF in Light.
 }
}
   

  • In the following video we can see the operation of the LED with LDR.

    Circuit designing of LDR : -

  • For more understanding about the LDR circuit. I have design the the board for LDR sensor. I have design the PCB board because on bread-board we may get the different result and it may not be same for actual PCB board.

  • I have used Eagle PCB designing tool for the circuit designing. To know the deatil information about Eagle refer Electronic design week.

  • I have used the reference of " hello world board design " from the page of Embedded programming week's schedule of Fab academy 2020.


  • Week1-1


      Wire diagram for connections between LDR and Atatiny44 : -

      As shown in the below image, one pin of ldr is connected to VCC and another pin is connected to Pin no.5 i.e. PB2 of ATtiny44. So that to trigger/activate ldr.


    Week1-1


  • Schematic of the LDR circuit : -

Week1-1

  • Board designing of the LDR circuit : -

Week1-1

  • In the below we can see the PNG images of trace and cut file of LDR circuit.



  • I have design this board of LDR only for detecting the light intensity and will shows the Lux readings on the serial monitor on uploading the code.

  • Then Milled the PCB board on SRM-20 Refer Electronic Production week. to understand the milling and soldering process of PCB board.

    Error : -

  • In the previous circuit I have used the basic components required for Atatiny 44 micro-controller and have added the basic footprint of resistor. Where I will solder the two legs of Surface mount resistor.

  • In this circuit I have used only one resistor of 10k Ohm. The circuit does not work, it was not showing the readings. I was unable to understand why is it happen. Also in the circuit diagram, I have done more mistakes that I have not connected the capacitor with the resistor. Because of this problem my circuit was not working properly. Hence I have decided to redesign the circuit.


Week1-1


    Basic components require for Atatiny44 : -

  • Atatiny 44.

  • Resistor of 10K.

  • Capacitor of 1uF.

  • Resonator of 20MHz.

  • FTDI header.

  • ISP programmer header.

    To resolve the problem I have added one more footprint of the resistor in my design and have connected the capacitor with resistor. After milling the circuit I have solder the resister of 100 Ohm along with other componentes.

Week1-1

  • This is the image of board file I have design in Eagle.

Week1-1

  • These are the PNG images of new design file.



    Hero-shot of the new board : -



    Programing the board : -

    For programing the board with above program which I have used to program the LED on breadboard, go to Arduino ID environment select the microcontroller as Atatiny 44. Select external frequency 20MHz. As I have program my board through my ISP programmer that I have designed in the Electronic production week. Therfore I have select USBtiny ISP programmer from the tool menu. For detail process of programming refer Embedded programming week.

    Ldr on the board showing the readings on serial monitor : -

    BH1750 light sensor : -

  • In my final project I have used BH1750 light sensor to get more effective result of Light intensity.

  • BH1750 This is BH1750 light intensity sensor breakout board which I am using in my project to get more effective reading.

  • Bh1750 is a digital Ambient Light Sensor IC with IIC (i.e. Inter-IC) bus interface. This IC is most suitable to obtain the ambient light for adjusting the other devices like LCD, Keypad backlight etc.

  • Photo diode on BH1750 detects the light intensity, which is converted as voltage output with the help of an integration-OPAMP.

  • the built in AD (analoge to digital) converter finally gives out the 16bit digital data.

  • Internal logic of BH1750 avoids the need for any complicated calculations, as it directly gives the output in meaningful digital data in Lux(Lx).

Week1-15

    Image of project board : -

  • For controlling the input and output I have used Atmega328p micro-controller. The description of other components are given in the Final project page.

Week1-1

    Set up for programming the board : -

    Pins of BH1750 light sensor and their description.


Week1-1


  • As shown in the above image. BH1750 has 5 pins:

  • a) VCC :- 2.4V to 3.6V

    b) GND :- Ground

    c) SCL :- Serial Clock

    d) SDA :- Serial Data

    e) ADDR :- I2C Addresss Selection

    Connections of the various pin of Micro-controller with BH1750 : -

    a) VCC is connected to Pin no. 4

    b) GND is connected to Pin no. 21

    c) SCL is connected to Pin no. 28

    d) SDA is connected to Pin no. 27

    e) ADDR is connected to Pin no. 26

  • As I have explain above ADDR pin is a address pin. This pin is used when more than one module of I2C devices (here it is BH1750 sensor) are connected to the board.

  • After designing the board and connecting the sensor to the board, I have program the board by connecting BH1750 with ADDR pin.

  • For the next time I have program the same board by connecting ADDR pin of BH1750 with the ADDR pin of my board. Both the time I have get the same result that BH1750 sensor shows the readings of light intencity on the serial monitor. From this I have get the conclusion that it is not mandatory to connect ADDR pin of sensor with the ADDR pin of our board unless we are using more than one module of BH1750 in our circuit. As ADDR pin select the right address of the BH1750 module whose readings we need to display on the serial monitor.

  • I also have refer this document to know about the ADDR pin of BH1750 light sensor.

  • For getting the I2C address of BH1750 I have connected the sensor with ArduinoUNO and have upload the I2C_scanner code.

  • By uploading this code we can get the I2C address of the device on the serial monitor.

    Code used for programming : -

  • For programming any board to operate it with BH1750 we need to include the library of BH1750 Click here for the library of BH1750.

  • Or copy this link in the " https://github.com/claws/BH1750.git " in the " Preferances " in the " File " menu of " Arduino IDE " as shown below.

  • Week1-1


	

                
//modified by : Tejswini Chaudhari
// "BH1750" light sensor reading.


#include <Wire.h>
#include <BH1750.h>


BH1750 lightMeter;
	

void setup(){



    Serial.begin(9600);
	
	
    // Initialize the I2C bus (BH1750 library doesn't do this automatically)
    Wire.begin();
    // On atmega328p you can select SCL and SDA pins using Wire.begin(D4, D3);
	
	
    Serial.println("Running...");
    lightMeter.begin();
    Serial.println("Running...");


}	


void loop() {


    float lux = lightMeter.readLightLevel();
    Serial.print("Light: ");
    Serial.print(lux);
    Serial.println(" lx");
    delay(1000);


)

    Working of BH1750 showing readings on serial monitor : -

    In the below vedio we ca see the operation light intensity readings of BH1750 sensor.

    To use Arduino UNO as FTDI : -

  • To use " Arduino UNO " as a serial-to-usb monitor or can be use as a FTDI we have to burn a code in the Arduino UNO .

  • Go to File, click on the Examples, select ArduinoISP code from the list.


Week1-1


  • The following code is get open on the screen this is the code which will allow our Arduino UNO module to act as a serial-to-usb monitor.


Week1-1


  • Now we need to select board and ISP i.e programmer. For that go to Tools select Arduino/Genuino board and ArduinoISP programmer.

  • After selecting the board and programmer, connect our ArduionUNO board to the computer with Arduino cable and burn or upload the program.


Week1-1


    Now we can connect our board with ArduionUNO pins to show the readings of input sensor on the serial monitor. To use ArduinoUNO module as a FTDI, we need to connect,

  • GND of programming board to GND of ArduinonUNO.

  • VCC of programming board with 5 Volt VCC of ArduinoUNO.

  • Rx of programming board with Rx of ArduinoUNO.

  • Tx of programming board with Tx of ArduinoUNO.

  • This connection will allow Arduino-UNO to transfer the data from the input sensor on our board to the serial monitor of ArduinoIDE.

    Following image shows the connections of ArduionUNO as FTDI.


Week1-1


    Connections ArduinoUNO to work as a programmer : -

  • We can program our board with ArduinoUNO module. The ArduinoISP code have the connections of programming pins. Which we can use to program our board instead of using ISP programmer.

  • I have tried it just for getting extra knowledge. For that I have connect the board with the progarmming pins of Arduino-UNO with the following connections.

  • Arduino UNO pin connections with ATmega 328p : -

  • Pin no. 13 : - SCK

  • Pin no. 12 : - MISO

  • Pin no. 11 : - MOSI

  • GND of arduino uno : - GND of ATmega328p

  • 5V-VCC of arduino uno : - VCC of ATmega328p

  • In the image below I have shown the connections between ATmega328p which is the microcontroller on my project board and Arduino UNO , for acting as a programmer.

    We can use these pins of ArduinoUNO to program the board.

Week1-1

    Download design files : -

    Learning outcomes : -

  • In this week I ahve studied about what is input devices and how they work.

  • I have learned about Ldr and also have prepair its circuit on breadboard and have milled the PCB to get clear idea of its working.

  • In this week I have learn about BH1750 light sensor and how it is more effective for my work.

  • I have learned some more information about coding by writing the code for Ldr and BH1750 sensor.

Creative Commons License
Solar Automatic Shredder by Tejswini Chaudhari is licensed under a Creative Commons Attribution-ShareAlike 4.0
International License