[BPI accessories] BPI-BerryClip Module and how to use

Product specification Product Overview: The module is designed specifically for learning control the GPIO of Banana Pi. There are 6 LED, 1 button and 1 Beep on the module; All of them can use the GPIO of Banana Pi to control. The beginner can learn the INPUT mode of GPIO through the key and learn the OUTPUT mode through the LED or Beep

Product Feature: 6 multicolor LED 1 single button on board 1 Beep on board

Port: BananaPi 2X13 port

Product Parameters: Working voltage: 3.3V LED max current allow 8mA Beep max current allow 12mA Typical Application: Hardware beginner learning Education How to use: Insert the BerryClip in the Banana Pi, Pay attention don’t make the direction reversed! The correct direction of insert module is above the Banana Pi’s PCB.

Testbench: Setup the GPIO OUTPUT, Output LED High level, the LED will be lighten; Setup the GPIO INPUT, press the button; Test finish

Example and Test Code:

#include <wiringPi.h>
#include <pcf8574.h>

int LED1[]={7,0,3,12,13,14};
int i;

int initIO()
{
    pinMode(7,OUTPUT);
    pinMode(0,OUTPUT);
    pinMode(3,OUTPUT);
    pinMode(12,OUTPUT);
    pinMode(13,OUTPUT);
    pinMode(14},OUTPUT);
}

int LED()
{
    for(i=0;i<=6;i++)
    {
        digitalWrite(LED1[i],1);
        delay(500);
        digitalWrite(LED1[i],0);
        delay(500);
    }
}

int main()
{
    int val;
    wiringPiSetup();
    pcf8574Setup(200,0x27);
    initIO();
    pinMode(10,INPUT);
    digitalWrite(11,1);
    while(1)
    {
        blink();
        val=digitalRead(10);
        if(val==0)
        {
            LED();
            digitalWrite(11,1);
            i=0;
        }
        else
        blink();
    }
    
}