Virtual Pressure Gauge Part 2.

Introduction: Virtual Pressure Gauge Part 2.

This project is the second part of a project I made earlier. In the first part, I have designed a virtual pressure gauge that can be controlled with UP and DOWN keys in your computer keyboard. see Virtual Pressure Gauge Part1

This time we will control the gauge with a potentiometer. Basically what's happening is: the potentiometer will change the voltage reading at port A0 (Analog port of Arduino). Each voltage reading will correspond to a digital value between 0 to 1023 bytes. The corresponding digital value will be sent to the computer via the serial port. The processing sketch will read the value from the serial port and will convert it into angle value, which will be the angle the needle will rotate to.

This is a cool project, quite fun, and very easy to make.

Enjoy.

Supplies

  • 1 x Computer (with processing and Arduino IDE installed).
  • 10k x potentiometer.
  • 1 x Arduino Uno with its USB wire.

Step 1: Step 1: Potentiometer Circuit With Arduino.

The potentiometer circuit is a very straight forward circuit:

  • 1 pin is connected to the power source.
  • the other pin is connected to the ground and the middle pin is connected to A0 of the Arduino.

Step 2: Step 3: Writing Arduino Sketch and Load It to the Uno.

This is a simple and straight forward sketch.

The voltage value is sent to A0 port, the analogRead command will give a value between 0 to 1023 bytes

Since the Serial module in the processing IDE can only read values from 0 to 255, we will have to divide the values from analogRead by 4.

This is why we have this command :

" data = analogRead(pressurePin)/4;"

Step 3: Step 3: Writing the Virtual Gauge Software.

This sketch is a modified version of the one in part 1. A straight forward sketch. basically what's happening in this sketch is that the Processing IDE read the value from the serial port, this value gets converted into angles value between 0 and 1.5PI radians.

angle = map(val,255,0,0,1.5*PI);

Angle 0 corresponds to pressure 0 and angle 1.5 PI corresponds to the maximum pressure.

One important thing to remember is that you need to know first on which port Arduino is connected. you can get this information from the Arduino IDE. In this project, Arduino was connected in "COM6".

Line 5 in processing IDE show:

<strong>String portName = Serial.list()[2];</strong>

This line tells to the processing IDE that Arduino is on COM6, by giving the value of 2 in the between []. read the comments in the script for more information.

Step 4: Connecting and Testing

First Time Author Contest

Participated in the
First Time Author Contest

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge
    • Robots Contest

      Robots Contest

    Comments