Header Image

Jak vyrobit (téměř) cokoliv

Week 6

Weekly tasks

  1. Use a sensor from a JVC kit or rental parts to measure a physical quantity using an Arduino.
  2. Calibrate the sensor (show the conversion relationship between the measured and indicated value in a graph or table).
  3. Put the wiring diagram and source code on the site
  4. Bonus: Build your own capacitive sensor using a piece of conductive material and also calibrate it

Used tools

Arduino nano, Arduino IDE

ArduWHAT

To be honest, before the start of this course I didn't quite understand what Arduino is exactly. I could be ashamed of it but I never had a chance to come across it during all my studies. It seems like some type of black box, where you are sending some code and it does what you want. During the lecture was said that you should do something that would challange your skills. Because of the epic fail that was my kinetic structure last week, this week I tried to do something simple.

ArduHOW

The journey started with installing Arduino IDE. I really did not want to mess up so I found and followed exactly this tutorial (and yes I made sure I didn't connect GND and 5V together)... and it is not that hard? Maybe I thought that it would involve some complexity but it is really just playing with wires and finding some working script on the internet. I modified the script that was in mentioned tutorial to have some interactive output in form of lighting of the LEDs.


    void setup() {
        pinMode(2, OUTPUT); // Trigger pin for sensor
        pinMode(4, INPUT);  // Echo pin for sensor
        pinMode(6, OUTPUT); // LED for <4cm
        pinMode(7, OUTPUT); // LED for 4-8cm
        pinMode(8, OUTPUT); // LED for 4-8cm
      
        Serial.begin(9600);
      }
      
      void loop() {
        digitalWrite(2, LOW);
        delayMicroseconds(4);
        digitalWrite(2, HIGH);
        delayMicroseconds(10);
        digitalWrite(2, LOW);
      
        long t = pulseIn(4, HIGH); 
        long cm = t * 0.0343 / 2;  //speed of light 343 m/s, light go to object and returns - devide by 2
        
        Serial.print(cm);
        Serial.println(" cm");
      
        // LED logic
        if (cm < 4) {
          digitalWrite(6, HIGH); // LED for <4cm ON
          digitalWrite(7, LOW);  // LED for 4-8cm OFF
          digitalWrite(8, LOW);
        } 
        else if (cm >= 4 && cm <= 8) {
          digitalWrite(6, LOW);  // LED for <4cm OFF
          digitalWrite(7, HIGH); // LED for 4-8cm ON
          digitalWrite(8, LOW);
        } 
        else {
          digitalWrite(6, LOW); // Both LEDs OFF
          digitalWrite(7, LOW);
          digitalWrite(8, HIGH);
        }
      
        delay(500);
      }
      
    
The final process
Scheme of wiring

To show wiring diagram I used Fritzing program

If there's one thing practical physics measurements has taught me, it's that everything has a measurement error. There are generally several measurement errors: instrumental error, errors arising from different approximations, and error of the person who is measuring. Let assume we can neglect every type of error except for the instrumental one. The ultrasonic sensor from its nature is not very accurate so calibration doesn't do much - but I did it anyway, if only because it was in the assignment - so I measured 10 different values and compare it with ruler.

Calibration