background image

 

 

 

 

 

 

 

  

 

 

 

 

 

 

 

 

   

 

   

 

   

 

 

 

 

 

 

 

 

 

   

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   

 

  

 

 

 

 

 

 

 

     

 

 

 

 

   

 

 

 

 

 

 

 

 

 

 

 

 

 

    if

 

((touchstatus

 

&

 

(1<<j)))

 

      touc+;

 

  }

 

  if

 

(touchNumber

 

==

 

1)

 

  {

 

    if

 

(touchstatus

 

&

 

(1<<SEVEN))

 

    {

 

      digits

 

=

 

'7';

 

    }

 

    else

 

if

 

(touchstatus

 

&

 

(1<<FOUR))

 

    {

 

      digits

 

=

 

'4';

 

    }

 

    else

 

if

 

(touchstatus

 

&

 

(1<<ONE))

 

    {

 

      digits

 

=

 

'1';

 

    }

 

    else

 

if

 

(touchstatus

 

&

 

(1<<EIGHT))

 

    {

 

      digits

 

=

 

'8';

 

    }

 

    else

 

if

 

(touchstatus

 

&

 

(1<<FIVE))

 

{
  int touchNumber = 0;
  uint16_t touchstatus;
  char digits;
  touchstatus = getTouchStatus();
  for (int j=0; j<12; j++)  // Check how many electrodes were pressed
  {

The loop function is actually empty currently, as the button presses use the interrupt we created in 
the setup loop. If you did have additional hardware you wanted to incorporate into your project, the 
code for it can live in this loop.
The last two functions in the example code tell the Arduino to check the electrode states for a button 
press and what to print out when a button press is detected.
void getNumber()

    {
      digits = '5';
    }
    else if (touchstatus & (1<<TWO))
    {
      digits = '2';
    }
    else if (touchstatus & (1<<NINE))
    {
      digits = '9';
    }
    else if (touchstatus & (1<<SIX))
    {
      digits = '6';
    }

    else if (touchstatus & (1<<THREE))
    {
      digits = '3';
    }
    Serial.println(digits);

}

  
  
    
  
    

w w w . e k t

2

. c o m

Electronics 

Katrangi

 Trading

Summary of Contents for Arduino R3

Page 1: ... pins and to digital pin 2 This connects to the INT pin on the MPR121 sensor We generally use stackable headers for attaching shields to Arduino boards but you can use standard male headers if you prefer The R3 Stackable Header Kit is the easiest option to use if you are planning on stackable headers For detailed instructions on how to assemble your shield have a look at our Shield Tutorial The sh...

Page 2: ...lso defined as D2 This can t be modified without some hardware hacking on the shield so keep that in mind if you are interfacing additional hardware into your set up void setup make sure the interrupt pin is an input and pulled high pinMode irqPin INPUT digitalWrite irqPin HIGH configure serial out Serial begin 9600 initalize I2C bus Wiring lib not used i2cInit initialize mpr121 mpr121QuickConfig ...

Page 3: ...ently as the button presses use the interrupt we created in the setup loop If you did have additional hardware you wanted to incorporate into your project the code for it can live in this loop The last two functions in the example code tell the Arduino to check the electrode states for a button press and what to print out when a button press is detected void getNumber digits 5 else if touchstatus ...

Page 4: ...onal buttons here You will also need to update the code You ll want to add the following block of code into the example sketch right beforeSerial println digits You can change the digits values to have the buttons output different values instead of A B or C else if touchstatus 1 ELE9 digits A else if touchstatus 1 ELE10 digits B else if touchstatus 1 ELE11 digits C do nothing if more than one butt...

Reviews: