level 1
/*
TouchWheel.pde
MPR121 WhellPad Example Code
by:Waiman Zhao
Mail:[email protected]
created on: 11/2/14
license: CC-SA 3.0
Hardware: 3.3V Arduino Pro Mini
SDA -> A4
SCL -> A5
IRQ -> D2
*/
#include <Wire.h>
#include <mpr121.h>
#include "Keyboard.h"
int key = 0;
// ========= setup =========
void setup()
{
// initialize function
Serial.begin(19200);
Wire.begin();
CapaTouch.begin();
// initialize control over the keyboard:
Keyboard.begin();
delay(500);
Serial.println("START");
}
// ========= loop =========
void loop()
{
key = CapaTouch.keyPad();
if (key == 11)
{ Serial.print("key:");
Serial.println("*");
Keyboard.write('*');
}
else if (key == 12)
{
Serial.print("key:");
Serial.println("#");
Keyboard.write('#');
}
else if (key >= 0) {
Serial.print("key:");
Serial.println(key);
Keyboard.write('0' + key);
}
delay(200);
}
2023年03月12日 02点03分