Project Sniffles – Sensory Replication using Arduino – Final Week

Upon completion of the project and on the day before hand in our final post will be a collection of the final model, a in depth flowchart and code that we used to power him.

First is the completed model. This is something me and Stefan are immensely proud of, it took a while for the plushie to get here but when it arrived we really needed to crack the mechanism and internals. As you can see from the images and the video below it works well and performs reliably. Only thing that we want to change later is the servo’s angle. Currently it’s at 90 degrees at rest then 180 when curled up. We can’t get any more rotation on the servo as it won’t go past 180 and would require us to take him apart so something to do after

Next our code was a tricky nut to crack but we got there in the end. We had a working code early on but we felt like with the extra time we could really get a complex and cohesive code. One problem we wished we could fix was the vibration motor with varying speeds at different distances. This wasn’t possible with the time as servo’s and DC motors don’t like working together with Arduino.

A1 Code.jpg

The circuitry for Sniffles was basic enough because we used a lot of code to control things. We made a voltage regulating circuit to control the DC motors but in the end, we had to stick to digital writes (ON & OFF) because of our code problem. Again, we intend to change this before our second-year show.

#include <Servo.h>
Servo Servo1;
int motorPin = 8;
int ServoPin = 3;
int trigPin = 10;
int echoPin = 13;
int cases;
int distance;

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(motorPin, OUTPUT);
  Servo1.attach(ServoPin);
}

void loop() {

  proximity();

  if (distance <= 20 && distance >= 2)
    cases = 1;
  if (distance <= 30 && distance >= 21)
    cases = 2;
  if (distance <= 40 && distance >= 31)
    cases = 3;
  if (distance >= 50)
    cases = 4;



  switch (cases) {
    case 1: //full scare
      // Write servo to the scared position
      Serial.println(cases);


      digitalWrite(motorPin, HIGH);

      Servo1.write(180);


      break;

    case 2: // full shake no scare
      // revert servo back to the original
      Serial.println(cases);

      digitalWrite(motorPin, HIGH);

      //      if (Servo1.read() == 180)
      //        for (int i = 180 ; i > 90 ; i -= 2)
      //        {
      //          Servo1.write(i);
      //          delay(40);
      //        }

      Servo1.write(90);
      break;


    case 3: // semi shake
      // Vibrate
      Serial.println(cases);

      analogWrite(motorPin, LOW);

      //      if (Servo1.read() == 180)
      //        for (int i = 180 ; i > 90 ; i -= 2)
      //        {
      //          Servo1.write(i);
      //          delay(40);
      //        }

      Servo1.write(90);

      break;

    case 4: // not scared
      // Servo back to original
      Serial.println(cases);

      digitalWrite(motorPin, LOW);

      //      if (Servo1.read() == 180)
      //        for (int i = 180 ; i > 90 ; i -= 2)
      //        {
      //          Servo1.write(i);
      //          delay(40);
      //        }

      Servo1.write (90);
      break;

  }

  delay(100);
}

void proximity() {

  float duration;
 // int distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(10);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = int((duration / 2) * 0.0344);

  if (distance >= 400 || distance <= 2) {
    Serial.print("Distance = ");
    Serial.print(distance);
    Serial.println("Out of range");
  }
  else {
    Serial.print("Distance = ");
    Serial.print(distance);
    Serial.println(" cm");
//    delay(10);
  }
//  delay(1000);

  //return distance;
}



Overall me and Stefan are extremely proud of what we’ve done in the 3 months we had, to get a very well built model and code to work cohesively was a big task for us but we have done very well. We’ve finally got something that made us proud to present and show. Our favourite part of creating Sniffles was how well he has gone down with the people using him, showing that sensory replication using electronics can put smiles on people’s faces.

Thanks for following the blog!

Thomas Bown & Stefan Gution

Advertisements

Sensory Replication using Arduino – Project 2 – Week 5

This week being the final week where we can work on our project we really needed to get things finalised. We had nearly all the parts needed to make this a successful project nearly complete, but none completed.

gund-oliver-hedgehog-alt_1024x1024We started by creating a frame in the body and decided where the servo would sit. The servo is located at the top of the hedgehog’s head, where the arm will be the actuator that gives us a curling up effect. Using thread, we could create a nice connection with no visible joints. We were successful with attaching the servo and it was our first indication that this project could be something emotional for users to interact with

17548725_1396010883752922_1960908534_o17548893_1396010923752918_1392347117_o17571320_1396011010419576_1360199220_o

We also finally got to play with all our sensors and outputs and are in the stage of finalising our code and then wiring the sensors to the board to create our effect.

Thomas Bown & Stefan Guiton

 

Sensory Replication using Arduino – Project 2 – Week 4

Another week and more problems from amazon meant that we only received our hedgehog and servo on Friday. This meant that our work was really ground to a halt until Friday. So we made the most of the time in-between to make a little model on how we imagined our hedgehog would move with the servo’s.

17379706_1389183647768979_1972335322_o

 

From this we drove the tea towel as this was a similar material to the hedgehog we had ordered. It works with the hand operated model to really know what it does it needed servos to drive it.

 

From Friday, we finally got the hedgehog and servo, a relief and now we could start to see what changes we needed to make to the mechanism. After cutting the hedgehog open we understood that it may be better if only one servo was the driver for the top of the hedgehog. From the video below we thought it would reduce the problems that our mechanism would have with two and still get the same effect.

17408086_1389216387765705_1568562928_o

For the next week we intend to test the new mechanism we decided on and possibly create a final version to drive the hedgehog.

Thomas Bown & Stefan Guiton

 

 

Sensory Replication using Arduino – Project 2 Week 3

This week we planned to create our new mechanism with the help of the two servos we are using to drive the arms of the mechanism. This was the plan but due to Amazon losing our second servo in the post and then Amazon losing our soft toy where the mechanism would be housed we had to make adjustments to what we were going to do with our time.

gund-oliver-hedgehog-alt_1024x1024

So, our inputs that we decided on are sound and proximity. The idea is that when an object was within a set distance, the sound sensor would activate and if the sound was above a certain threshold it would then curl up.

So producing the code for actuating a servo with sound can be found below. A simple code that will read the audio from a sensor and then produce angled movement from the servo.

CODE FOR SOUND

due to the absence of our parts from amazon we decided that to make up for that we would generate the other code for our ultrasonic proximity sensor.

CODE FOR PROX

Tom Bown & Stefan Guiton

 

 

 

Sensory Replication using Arduino – Project 2 week 2

This week we decided that it would be helpful to create a small sketch model based on our new mechanism that would move the hedgehog.  From our sketch model, we discovered that this new way of moving the mechanism would work well. With the new mechanism, we would require two servos to drive the linkage arms. One arm is shorter than the other which represents the hedgehogs head moving in at a slower pace.

We tried to add servos to the sketch model to see if it would work but it became off centred and wouldn’t balance. From this we proposed a second iteration of our mechanism.

17160819_1375695322451145_1733182107_n

From this we propose a rotary movement with the servo that would transmit into the gears which then would allow the arms to rotate from the centre of the mechanism. Now this will provide a more stable and efficient way of moving the arms inside the hedgehog.

Thomas Bown & Stefan Guiton

Sensory Replication using Arduino Project 2 – Week 1

Following on from our last project, we saw this next one as an opportunity to really refine and produce something not only functionally beautiful but have a real experience when moving. We decided that we would take this further by producing our first project; the hedgehog but in a much more precise way.

www.hdnicewallpapers.com
http://www.hdnicewallpapers.com

Firstly, we would look at making the models movement more fluid and compact. By doing this we are really going to push the project so it can fit inside a plushie Hedgehog and when you interact with the hedgehog it would react to whatever input it we decide upon (Heat/Motion/Noise).

il_fullxfull-302333798

We started by looking at the motion of the hedgehog. Before we used a parallel linkage to drive the curl effect but this time we would need a more rounded effect. We sketched a few ideas that we are going to start to sketch model to get an idea how the movement works in the physical world.

Thomas Bown & Stefan Guiton

Sensory Replication using Arduino – Week 5

In this last week of the project we had quite a bit of work to do. We started our week with getting the final model built and built well. It took a lot longer than anticipated as the linkage wasn’t working well with the rail system we had. Too much friction or too little friction allowed for the linkage to fail. This was resolved with small 2mm aluminium tubes which allowed a snug fit and a nearly friction-less connection.

16810210_1359326677421343_1413944825_o

 

We also had to use a different type of code as the initial one worked for one rotation but then looped constantly. This code type is called a switch case code, this allowed us to have a check if the button had been pressed and if it has been pressed currently. With more cases led to more control over the servo which did fix our problem and is all around a better code.

flowchart

All in all, we were happy with the way the project turned out and were excited to be taking this project to the next level by using it in our next project for the semester.

Thomas Bown & Stefan Guiton

ezgif.com-optimize (1).gif

Sensory Replication using Arduino – Week 3

This week we decided to start thinking about the actual model we would be making to represent the curling of the hedgehog. Our thoughts and quick ideation led us to a model that would have a single step motor/cervo that would pull some thin rope.

 

16558979_1350666721620672_1232899426_n

The sketch above illustrates what we intend to do with the physical model. Each end of a small bar on the end of the motor has a small string attached to the ends of the bar. When the motor/cervo rotates, because of the tension the attached legs will move closer to the motor which causes the rigid structure to curl up into a compact shape.

16466774_1348228715197806_167900168_o

We produced a small sketch model that gave us a real-life version of our theory. Made from sketch model materials like lolly pop sticks and wire we could get it moving in a similar movement as we sketched out.

video-1486132520.gif

Thomas Bown – Stefan Guiton

 

Sensory Replication Using Arduino – Week 2

After deciding what nature based inspiration source to use for our project, attention was shifted to how we though the scene would play out with the all the inputs and outputs in a real-life scenario.

untitled

So as the car would come closer to the hedgehog, the animal would sense it was getting closer through the intensification of the vibrations it could feel in the ground. Next the hedgehog would curl up into a ball and shake, retreat away from the road and possibly shriek.

giphy

So, identifying the scenario led to the development of what we needed to sense and then output based on that sense. First was the sense of vibration (main input as the hedgehog can’t see the car. Then our output would be the hedgehog shaking and then making a noise as if it was scared.

To do this we would need these specific electronics to do so:

  • Piezo Vibration sensor (input)

41sbs1rbzxl-_sx355_

 

 

 

 

 

 

  • Vibration Motor (output)

DC vibration micro motor

  • Speaker (output)

fii0d11iap6ug5a-medium

  • Step motor (for movement if we want added complexity)

10551-01.jpg

Thomas Bown & Stefan Guiton

Sensory Replication using Arduino: Week 1- Stefan Guiton & Thomas Bown

When looking for ideas for our first physical computing project, we had a look at nature to see examples of where a plant or animal would react to sound and or vibration, we came across two examples, the first being the millipede, which curls up whenever you walk closely to it.

hedge

We then went on to look at the hedgehog for inspiration. The hedgehog curls up into a ball once it feels that is in danger, when a car drives near it, it reacts to the loud noise the car is making and the vibration that the hedgehog feels through its feet from the car driving on the ground near it. I have also noticed that hedgehogs shiver in fear and make a little noise when they are curled up.

hedgehog

 

From our inspiration, we decided to make a simple device that would react to both sound and vibration as inputs and produce sounds with vibrations as the output.

outputuntitled-1

.