# Arduino Paper Controller (Buttons, Slider)

690

11

2

## Introduction: Arduino Paper Controller (Buttons, Slider)

View this project on my website!

This project allows you to draw your own controller to be used with anything. It utilizes capacitive sensing and the conductive properties of graphite to send data to an Arduino board.

• Materials:
• Alligator clips
• Arduino
• Jumper wires
• 10M Ohm Resistors (x3)
• Pencil
• Paper
• Servo Motor
• LED (x2)
• resistors for LEDs (Usually 220 Ohm) (x2)

## Step 1: Draw Controller

You are literally drawing your controller on a piece of paper:

• Be sure to use pencil (graphite is conductive)
• Make a few buttons and maybe a slider or two.
• Be sure to draw a line leading to the edge of the paper to give room to the alligator clips

## Step 2: Make Circuit

I forgot to include the two led resistors (just pretend they're between ground and the anode on both). The three black boxes on the right are meant to be the alligator clips leading to the paper. (The top is the slider and the other two are buttons)

## Step 3: Install Library

The code for this project requires a library designed to use capacitive sensing. Download it here: https://playground.arduino.cc/Main/CapacitiveSens...

According to the Arduino page for this library, "The capacitiveSensor library turns two or more Arduino pins into a capacitive sensor, which can sense the electrical capacitance of the human body. All the sensor setup requires is a medium to high value resistor and a piece of wire and a small (to large) piece of aluminum foil on the end. At its most sensitive, the sensor will start to sense a hand or body inches away from the sensor."

```#include <Servo.h>
#include <CapacitiveSensor.h>

Servo myservo;

CapacitiveSensor   button1 = CapacitiveSensor(4, 2);
CapacitiveSensor   button2 = CapacitiveSensor(4, 3);
CapacitiveSensor   slider = CapacitiveSensor(4, 5);

int total1val = 1000;//you'll need to edit these
int total2val = 1000;
int total3val1 = 100;
int total3val2 = 1000;

void setup() {
//button1.set_CS_AutocaL_Millis(0xFFFFFFFF);
Serial.begin(9600);
pinMode(10, OUTPUT);
pinMode(13, OUTPUT);
myservo.attach(6);
}

void loop() {
long start = millis();
long total1 =  button1.capacitiveSensor(1000);
long total2 =  button2.capacitiveSensor(1000);
long total = 0;
long total3 = 0;

for (int i = 1; i <= 10; i++) {//averages the value for the slide to make the servo smoother
total3 =  slider.capacitiveSensor(10000);
total = total + total3;
delay(1);
}

long avg = total / 10;
int angle;

Serial.print(millis() - start);
Serial.print("\t");

Serial.print(avg);
Serial.print("\t");
Serial.print(total2);
Serial.print("\t");
Serial.println(total3);

if (total1 > total1val) {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}

if (total2 > total2val) {
digitalWrite(10, HIGH);
}
else {
digitalWrite(10, LOW);
}

angle = map(avg, total3val1, total3val2, 180, 0);
myservo.write(angle);

delay(10);
}```

You will likely need to adjust the values at the top by the "//you'll need to edit these" comment:

• Open the serial monitor to watch the values come in
• Look at the value both "low" and "high" (when you are and aren't touching the button)
• Adjust the values in the code until everything works properly (the LEDs should turn on when you press the buttons and the servo should turn accordingly)
{"ft_lang_label":"__label__en","ft_lang_prob":0.7693246,"math_prob":0.8487119,"size":3615,"snap":"2021-04-2021-17","text_gpt3_token_len":940,"char_repetition_ratio":0.13043478,"word_repetition_ratio":0.0,"special_character_ratio":0.27219918,"punctuation_ratio":0.15889212,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96389586,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-20T11:29:54Z\",\"WARC-Record-ID\":\"<urn:uuid:67d8d348-b0e8-49a2-b7f4-20472bbc6178>\",\"Content-Length\":\"57566\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:77850d37-297a-41dc-b20e-bea025c63c98>\",\"WARC-Concurrent-To\":\"<urn:uuid:25c74e70-2cd7-4a73-b710-56a981a4473d>\",\"WARC-IP-Address\":\"199.232.65.105\",\"WARC-Target-URI\":\"https://www.instructables.com/Arduino-Paper-Controller-Buttons-Slider/\",\"WARC-Payload-Digest\":\"sha1:SPN5SJ6BTZ33FY4V3OZHH6WPPNC3BF3M\",\"WARC-Block-Digest\":\"sha1:LDMOKXBOX5EH6ZR7NUKJA35C4VR3NV6B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703519984.9_warc_CC-MAIN-20210120085204-20210120115204-00763.warc.gz\"}"}