viernes, 10 de enero de 2020

PROBAR LA IR ARRAY

The IR Array consists of 3 IR (Infrared) sensors. Look closely and you will see that each sensor has two ‘dots’, one blue and one black. The blue one is an IR LED and the black one is the actual IR sensor. When connected to power, the IR LED emits infrared light. You can not see it with your own eyes but if you have a camera in your mobile phone you can direct it towards the LED and on the mobile screen you will see the IR light very clearly. When you hold the sensors close to a white surface, the white surface will reflect a lot of the IR light emitted by the LED, which will be detected by the IR sensor. If you hold it over a black surface, instead almost no IR light will be reflected. This is how it can distinguish black from white.


Materials


  • 1 x control board
  • 1 x Education Shield
  • 1 x IR Array
  • 5 x jumper wire

Instructions

  • Step 1

  • Step 2

  • Step 3




  • IR Array 6 pin


  • IR Array 10 pin

    1. Attach the shield onto the top of the board.
    2. Connect AN1 to A1, AN2 to A2 and AN3 to A3.
    3. Connect the IR Arrays GND to GND and VCC to power.
    4. Connect the board to the computer and upload example ‘IRArray’.

    Code

    Find the code in File>Examples>EducationShield>Help>IRArray
    http://verkstad.cc/urler/ctc-g-r-21

    Result

    You should now open the serial monitor and move the IRArray over a black or white surface. If a sensor is over a black surface, a value around 330 should be printed, if over a white surface, the value should be around 400.

    Commands

    • IRArray( AN1, AN2, AN3 ): Creates an IRArray object
      • Parameters
        • (int) AN1: the analog pin to which the first IR sensor is connected to.
        • (int) AN2: the analog pin to which the second IR sensor is connected to.
        • (int) AN3: the analog pin to which the third IR sensor is connected to.
    • test(): prints all the IR sensor readings to the serial monitor.
    • setThreshold(threshold): Sets the threshold value between black and white. Use test() first to check the readings from black and white, then decide on a threshold value between those values.
      • Parameters
        • (intthreshold: The threshold value between black and white. If you’re using the CTC 101 board the threshold is 530, if you’re using the CTC UNO board its 380.
    Related commands:
    • readLine(): returns the direction of a black line on a white surface.
      • Return
        • (int): Value between -100 to 100. When it is close to 0, the IR array is in middle of the black line. When it is close to -100 or 100, it is offset to the sides.
    • readBinary(): Returns the decimal value combined from the individual IR sensor readings.
      • Return
        • (int): A value between 0 and 7. See table below for the value representation.

    Troubleshooting


    • Make sure the connections between the IR Array, wires and board are correct.
    • If you move IR1 from black to white but only the value of IR2 is changed, you need to either change the analog pins in the code or change the connections to the analog pins on the board.
  • No hay comentarios:

    Publicar un comentario