The ArduCAM shield has 6 general purpose IOs which can be set as input or output and greatly extend the power for the Arduino board which has limited IO resources. The structure of the IOs in the ArduCAM shield is the same as the one in the AVR chip, it has a direction register(DDR), a input register(PIN) and output register(PORT). In this demonstration, we will illustrate how to set the GPIOs in the ArduCAM shield as an input and use a PIR sensor triggering the shield to start a capture.

PIR(Pyroelectric InfraRed sensors ) is a motion sensor for use in alarm burglar systems, visitor presence monitoring, light switches and robots. PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses. They are often referred to as PIR, “Passive Infrared”, “Pyroelectric”, or “IR motion” sensors.Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the ‘alarm’ pin will go high. We can use the PIR sensor to trigger the ArduCAM shield to take a photo for the scene.

Pin connection diagram between ArduCAM and PIR.In this demo we will use the IO0 connected to the PIR module.

Firmware guide:

In setup() routine we have to set the GPIOs to input like this

void setup()
{
  myCAM.write_reg( ARDUCHIP_DDR, 0x00);
}

In the loop() routine we have to polling the status of the GPIOs and start to take a photo when the PIR triggered.

void loop()
{
...  
  while(1)
  {
    gpio_trig = myCAM.read_reg(ARDUCHIP_PIN);            //Read external trigger from GPIO0~5
    if (gpio_trig & 0x01)      //if GPIO0 is high
    {
       k = k + 1;
       itoa(k, str, 10); 
       strcat(str,".bmp");    //Generate file name
       GrabImage(str);
    }

  }
...  
}

Full Arduino code can be downloaded from here.

End.

0
Your Cart is empty!

It looks like you haven't added any items to your cart yet.

Browse Products