week 5 – tom bolsover

this week i nailed down the code, this was done by much trial and error based around the sensor as well as adding time elements into the code so that the coaster can remind the user to either drink more or light up to show them that they are drinking enough.

 

int fsrPin = 0;
int fsrReading;
int fsrVoltage;
unsigned long fsrResistance;
unsigned long fsrConductance;
long fsrForce;

void setup(void) {
Serial.begin(9600);
}

void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.print(“Analog reading = “);
Serial.println(fsrReading);

fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print(“Voltage reading in mV = “);
Serial.println(fsrVoltage);

if (fsrVoltage == 0) {
Serial.println(“No pressure”);
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc – V) * R) / V
fsrResistance = 5000 – fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 5600;
fsrResistance /= fsrVoltage;
Serial.print(“FSR resistance in ohms = “);
Serial.println(fsrResistance);

fsrConductance = 1000000; // we measure in micromhos so
fsrConductance /= fsrResistance;
Serial.print(“Conductance in microMhos: “);
Serial.println(fsrConductance);

// Use the two FSR guide graphs to approximate the force
if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
Serial.print(“Force in Newtons: “);
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance – 1000;
fsrForce /= 30;
Serial.print(“Force in Newtons: “);
Serial.println(fsrForce);
}
}
Serial.println(“DRINK”);
delay(1000);
}

Advertisements

Lewis Tudge/Jacob Avent – Week 4

This week we worked on coding for the servos. Having not had any experience with servos before, we spent time researching on the internet and looking at arduino’s built in examples for guidance. Having eventually written the code for the two servos, each to move to home position on start-up, then to move through 90 degrees (and back) to open and close the doors on our money box, we then worked on implementing this code within a button press counting code. We also worked on implementing the code from project one into the button counter, but found the original code needed to be re-written, without using delays.

Jacob Avent / Lewis Tudge – Week 3

Week 3

 

This week we decided to change our original idea of a cuckoo clock to a penny box that will show the fire flies when you insert pennies. This will be easier for us to code as we struggled to get the coding right for the clock on the Arduino.

For every penny inserted, a fire fly will show. We plan on having 2 fire flies. One will show for the first 5 pennies inserted and glow its tail. The second one will come out on the 6th penny inserted and flap its wings as well as glow its tail. Then it will all start again. Possibly a good way to collect money for charity?

 

Lewis Tudge / Jacob Avent -Week 2

Week 2

During this week we decided a cuckoo clock that pops out fire flies will be the best idea for us to run with. This is in addition to the fire fly clock idea that we had last week.

The fire flies we thought should be mounted on servos and pop out for us to tell the time.

To tell the time the first fire fly will come out and glow once for every 5 minutes past the hour.

Every hour the other fire fly will flap the number of hours it is.

week 4 – tom bolsover

in the 4th week i really focused building the product. as shown in the engineers drawings below. this product can be made without ardunino and thus could be made much smaller. this is show by having smaller electrical components no breadboard and few parts. the coaster can then be powered off a much smaller power supply. and be a much more slender design

Assembly1 2.1

Assembly1 2.2

Assembly1 2.3

 

 

 

 

 

Lewis Tudge/Jacob Avent – week 1

Lewis Tudge/Jacob AventDuring this week, we developed our firefly project by trying to implement the flapping and flashing firefly into a clock. We sourced a basic, open source clock code from https://www.faludi.com/examples/open-source-arduino-clock/ and started working on trying to have the firefly flap and flash according to the number of hours that had passed in the day. The clock code only outputs the time as a serial output, so we had to work on how to convert this output into useable outputs.

Arduino project 2 – week 6 – keaney/scotten

This week jemilla and I pulled together all of our componenets for the model and implemented the arduino inputs and outputs into the model. We had gotten our Model to react with sound, and in turn this sound, if loud enough, would cause the door on our model to open using a servo, as well as an LED turning on in our model to illuminate the insides which would otherwise be dark. If the input sound is not loud enough however then the door would open only a small bit then close again. the insides of our model involved a mountain landscape, with a scenic background and snow flying everywhere being driven mainly by a 9V battery as it was far too diffuclt or expensive to incorporate the correct power method into the model. IMG_1437

The model worked very well but due to account restrictions we are unable to upload a video as a demonstration. if we were to make the model again we would investigate a different form for the model and look into powering it properly but otherwise we were very pleased with how it turned out finally as shown below, appropriately named ‘BLIZZARD’

IMG_1432

week 3 – tom bolsover

in the third week i bought a force resistance sensor (which came with a free pack of harribo) off the internet. this allowed me to start testing with different weights and drinks. i found that different drinks had different weights such as beer was heavier than water but not as heavy as milk. i also researched how much water the average male and female needed to drink. males need to drink around 3.7 liters of water a day and females 2.7. i also calculated how to convert resistance to weight.20170402_171542

Project Ilum Kyrie Roberts, Joe Tapson Final Blog

Our final week in the project included the assembly of the final model as well as code refinements. The model involved the use of four, mounted, hexagonal boxes (two of which were fitted with sensors and LEDs/RGBs). The two functional modules were fitted with an Arduino Uno each to accommodate for two separate codes, one of which to change brightness according to distance and the other to change colour from blue to red.

Despite the use of 11 leds for the brightness changing box and 8 rbs (16 leds) for the colour changing box, only 2 PWM pins from each Arduino were used without fully draining the 5v supply. Last week the colour changing RGBs had an issue where the colour would transition from red to blue within 5cm of the ultrasonic sensor when the RGB should have stayed red. This issue was fixed when the code was altered to remove map functions.

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