Arduino Pattern Shield acts as Arduino Shield via 1Sheeld

Buy 1Sheeld
Arduino Pattern Shield

Pattern shield turns your smartphone to a secret pattern locker shield so Arduino can take actions by a certain patterns defined by user

This shield is one of the special shields.Special shields allow your Arduino board to use some capabilities your smartphone can do, like playing music, taking a picture, getting notifications, accessing the clock data and using the touch screen for various functions.Learn more from the special shields tutorial.

Pattern Library turns your smartphone to a secret pattern locker shield so Arduino can take actions by a certain patterns defined by user.

Adding #define CUSTOM_SETTINGS along with #define INCLUDE_PATTERN_SHIELD is a key that will let you unlock the Pattern shield only amongst all shields and prevent 1Sheeld library from eating your memory specially for UNO board.

Note

– Creates an instance of type Pattern to receive and parse patterns from the application.
– PatternNode is defined in Library to ease up saving and dealing with patterns and has two variables row and col to be updated.

Example

//oldPattern is an array of structures of PatternNode

PatternNode  oldPattern[] = { {0,0} , {0,1} , {0,2} };

// You can check equality of PatternNodes by using == and != operators

if(oldPattern[0]!=oldPattern[1])Terminal.print(“Not Equal!”);
//Accessing rows and columns of oldPattern by using .row and .col on a PatternNode.

byte row = oldPattern[0].row

byte col = oldPattern[0].col

PatternNode * getLastPattern(void)

Get the last pattern entered on your smartphone as an array.

 

SYNTAX
Pattern.getLastPattern();

 

RETURNS
Returns a PatternNode object holding the nodes patterns.

 

PARAMETERS
None.

 

USAGE
PatternNode * nodesArray= Pattern.getLastPattern( );

 

int getLastPatternLength(void)

Get the length of the last pattern array you entered.

 

SYNTAX
Pattern.getLastPatternLength();

 

RETURNS
Returns an integer holding the numbers of node selected.

 

PARAMETERS
None.

 

USAGE
int patternLength = Pattern.getLastPatternLength();

 

bool isNewPatternReceived(void)

Checks if there’s a new pattern received by the application.

 

SYNTAX
Pattern.isNewPatternReceived();

 

RETURNS
Returns a yes “1” or no “0”.

 

PARAMETERS
None.

 

USAGE
if(Pattern.isNewPatternReceived())
{
  PatternNode * incomingPattern = Pattern.getLastPattern( );
  int patternLength = Pattern.getPatternLength( );

  for (int i = 0 ;i < patternLenth ; i++)
  {
    /* Print out the pattern nodes selected. */
    Terminal.print(incomingPattern[i].row);
    Terminal.println(incomingPattern[i].col)

    }
  }

 

void setOnNewPattern(void(*userFunction)(PatternNode[],int))

Sets a certain function written by the user in the sketch to be called and runs its functionality once a new Pattern received.

 

SYNTAX
Pattern.setOnNewPattern(&userFunctionName);

 

RETURNS
None.

 

PARAMETERS
&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

 

USAGE
Pattern.setOnNewPattern(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked each time a new pattern is entered. */
void myFunction (PatternNode newPattern [] , int patternLength)
{
  for (int i = 0 ;i < patternLength; i++)
  {
    /* Print out the pattern nodes selected. */
    Terminal.print(incomingPattern[i].row);
    Terminal.println(incomingPattern[i].col)

    }
  }