Step 6: A working thing!

Now we can put it all back together to make something that works! 

A few tweaks were needed:
  1. Now that the flex sensor is tapped to the hinge, it is always a little flexed so the impedance is lower.  I changed the resistor to 10K.  
  2. The mapping from sensor input to servo angle needed to be adjusted a bit.  
  3. I also flipped around the pacman animation in processing and made it bigger for the photos.
After these adjustments the whole thing works pretty well.  It is a bit jittery, but that can be fixed.... (but I'm not going to).


This shows the back a little

Code with all the peices working nicely:

note: using 10K pullup resistor 

////////// Arduino Code ///////////////
//This is from an example inluded with Arduino IDE download.
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott
//MPC - added serial output 'n stuff

Here is the wiring:

Wiring -
|------Arduino Gnd
Encoder |------Analog 0
|------Arduino 5V

| Yellow ------ Digi 9 (PWM)
Top servo | Red -----------5V
| Brown -------Gnd

| Yellow ------ Digi 10 (PWM)
Bottom servo | Red -----------5V
| Brown ------

#include ; //use servo library

Servo myservo; // create servo object to control a servo
Servo otherServo ;

int potpin = 0; // analog pin used to connect the potentiometer
int val=0; // variable to read the value from the analog pin
int valComp;
int valOld=100;

void setup()
myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop()
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0,1023, 0,255);
if(val > 175){ //wide open
val = 185;
if(val <80){ //closed
val = 80;
if((abs(val-valOld))>7){ //filter out the jitter
valComp = val;
val = map(val, 80, 255, 90, 179); // scale it to use it with the servo (value between 0 and 180)
valComp = map(valComp, 255, 80, 0, 90);
myservo.write(val); // sets the servo position according to the scaled value
delay(10); // waits for the servo to get there
valOld = val;

//pacman moouth opens/close with X input from arduino output (flex sensor)

import processing.serial.*;
Serial port;
float x = 0;
float val = 0;
int frame = 1000;

float easing = 0.5;
float xOld;

void setup(){
String arduinoPort = Serial.list()[1];
port =new Serial(this, arduinoPort, 9600);

void draw(){
if (port.available() > 0) {
val = port.read();
//val = mouseX;
x = map(val,80,255,0.01,0.6); //translate values input to useful values/println(x);
background(100); //clear last image
float targetX = x;
x+=(targetX - x)*easing;
arc(frame/2,frame/2,frame/2,frame/2,(x)*PI,PI+(1-x)*PI); //draw packman, using radians... p21
//x= xOld;
Great example.
waka waka waka waka waka waka waka waka waka waka
so cute~
Love it.
GREAT instructable..<br>Really enjoyed it!<br><br>Just trying to think of what else could be done with it!
thank you! I like this news, I also have information to share, here is my message.we sale 60%-80% discount <br><a href=" http://www.mbts.es/">mbt</a> <br><a href="http://www.ugg-boot.nl/">ugg boots</a> <br><a href="http://www.ugg-boot.nl/">cheap uggs</a> <br><a href="http://www.ugg-boot.nl/">uggs</a> <br><a href="http://www.ugg-boot.nl/">ugg</a> <br><a href="http://www.fr-tiffany.com/">tiffany</a> or <br><a href="http://www.abercrombiefitchcloth.com/">Abercrombie</a> <br><a href="http://www.monclerjeans.com/">moncler</a> or <br><a href="http://www.aboutcl.com/">christian louboutin</a> or <br><a href="http://www.aboutcl.com/">cheap christian louboutin</a> <br><a href="http://www.aboutcl.com/">christian louboutin shoes</a> or <br><a href="http://www.airmaxtop.com/">air max shoes</a> or <br><a href="http://www.airmaxtop.com/">cheap air max shoes</a> or <br><a href="http://www.airmaxtop.com/">nike air max</a> or <br><a href="http://www.airmaxtop.com/nike-air-max-90-c-47.html">air max 90</a> or <br><a href="http://www.airmaxtop.com/nike-air-max-90-c-47.html">nike air max 90</a> or <br><a href="http://www.oppell.com/">air max</a> or <a href="http://www.oppell.com/">air jordan</a> or <br><a href="http://www.oppell.com/">air max shoes</a> or <br><a href="http://www.oppell.com/">air jordan shoes</a> or <br><a href="http://www.oppell.com/">nike air max</a> or <br><a href="http://www.oppell.com/">cheap air max</a> or <br><a href="http://www.oppell.com/">cheap air jordan</a> or <br><a href="http://www.us-linksoflondon.com/">links of london</a> or <br><a href="http://www.uggmanor.com/">UGGアグ</a> or <br><a href="http://www.uggmanor.com/">UGG</a> or <br><a href="http://www.mbtshop.jp/">mbt</a> or <br><a href="http://www.mbtfan.com/">mbt</a> or <br><a href="http://www.mbtcute.com/">mbt</a> or <br><a href="http://www.cheapestmbt.com/">mbt</a> or <br><a href="http://www.mbthere.com/">mbt</a> or <br><a href="http://www.us-linksoflondon.com/">links of londons</a> or <br><a href="http://www.us-linksoflondon.com/">cheap links of london</a> or <br><a href="http://www.us-linksoflondon.com/">Links of London Jewelery</a> or <br><a href="http://www.us-linksoflondon.com/">Links of London Jewellery</a> or <br><a href="http://www.fr-tiffany.com/">tiffany &amp; co</a> or <br><a href="http://www.fr-tiffany.com/">tiffany Jewelry</a> or <br><a href="http://www.fr-tiffany.com/">cheap tiffany Jewelry</a> or <br><a href="http://www.fr-tiffany.com/">tiffany Jewellery</a> or <br><a href="http://www.abercrombiefitchcloth.com/">Abercrombie fitch</a> or <br><a href="http://www.abercrombiefitchcloth.com/">Abercrombie &amp; fitch</a> or <br><a href="http://www.abercrombiefitchcloth.com/">cheap Abercrombie</a> or <br><a href="http://www.abercrombiefitchcloth.com/">Abercrombie fitch clothing</a> <br><a href="http://www.monclerjeans.com/">cheap moncler</a> <br><a href="http://www.monclerjeans.com/">moncler clothing</a> <br><a href="http://www.monclerjeans.com/">cheap moncler clothes</a> <br><a href="http://www.monclerjeans.com/">cheap moncler clothing</a> <br><a href="http://www.monclerjeans.com/moncler-jackets-kid.html">Moncler Jackets Kid</a> <br><a href="http://www.monclerjeans.com/moncler-jackets-kid.html">Moncler Jackets kids</a> <br><a href="http://www.monclerjeans.com/moncler-jackets-kid.html">Moncler Kid</a> <br><a href="http://www.monclerjeans.com/moncler-jackets-kid.html">Moncler Kids</a> shoes、clothing、Jewellery、bag、Watchs。
That is one of the coolest things I have seen. I really need to learn how to program.

About This Instructable


47 favorites


Bio: Married to Domestic_Engineer (but I call her Meghan).
More by marc.cryan: Cheapest, Bestest computer around, in beginning of 2015 Cryan Family Gothic Green House Small e-reader with oled + arduino, test
Add instructable to: