This goes along with a video on YouTube.
Code for Arduino’s plotter
void setup() {
// initialize serial communication at 9600 bits per second:
pinMode(A3, INPUT_PULLUP);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int p = analogRead(A0);
int t = analogRead(A1);
int r = analogRead(A2);
int b = analogRead(A3);
String st = String(p) + " " + String(t) + " " + String(r) + " " + String(b);
Serial.println(st);
delay (10);
}
code for use a game controller keyboard mode
include "Keyboard.h"
void setup() {
pinMode(A3, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
int p = analogRead(A0);
int t = analogRead(A1);
int r = analogRead(A2);
if (digitalRead(A3) == LOW) {
//Send an ASCII 'h',
Keyboard.write(104);
}
if (p < 300) {
//Send an ASCII 'j',
Keyboard.write(106);
}
if (p >900) {
//Send an ASCII 'l',
Keyboard.write(108);
}
if (t < 300) {
//Send an ASCII 'i',
Keyboard.write(105);
}
if (t >900) {
//Send an ASCII 'k',
Keyboard.write(107);
}
if (r < 300) {
//Send an ASCII 'q',
Keyboard.write(113);
}
if (r >900) {
//Send an ASCII 'e',
Keyboard.write(101);
}
delay(100);
}