Double Transducer: Rotation to Force


Brandt Li & Audrey Reiley

Final images

Overhead view of a double transducer. Cardboard square, with a potentiometer on the top, servo motor, with a magenta straw attached, on the bottom, and an LCD display to the right. There is a fan on the top left-right, with a wind sensor underneath it. Arduino in the center, connected with wires and breadboards, secured to the parts mentioned.

Audrey's double transducer (worked on demo day)

It is essentially an identical setup as the image above. Overhead view of a double transducer. Cardboard square, with a potentiometer on the top, servo motor, with a blue straw attached, on the bottom, and an LCD display to the right. There is a fan on the top left-right, with a wind sensor underneath it. Arduino in the center, connected with wires and breadboards, secured to the parts mentioned.

Brandt's double transducer (failed on demo day)

Detail photos

Close-up view of servo motor with a blue straw attached. The Servo motor sits on top of a stack of popsicle sticks wrapped with neon orange tape.

Servo Motor attached to straw to exert force

A close-up view of a red breadboard, showing the underneath with all the soldered components of the middle steps of our double transducer.

Pins and wires soldered to bread board

A close-up view of an LCD display that is turned on and in use. The values of the potentiometer, fan, wind sensor, and servo motor are displayed.

LCD Displaying active updates 

A close-up view of the fan and the wind sensor. The wind sensor is placed within the fan to detect its wind.

Wind Sensor inside fan to read wind

Final project movies

BRANDT.mp4

Brandt's double transducer (failed on demo day). The problem is between the wind sensor and the servo motor. It is assumed that there was an issue during soldering as it worked perfectly fine previously to the soldering. 

Audrey Reiley.mov

Audrey's double transducer (worked on demo day)

Narrative description

On one end of the cardboard, there is a potentiometer that has a metal knob that can be turned. Once the knob is turned, the speed on the fan that it is attached to will increase with the rotation of the knob. As the wind from the fan increases, it is read by a small wind sensor that tells the servo motor it is attached to, to increase rotation according to wind speed to apply force.

Progress images

Set up demonstrating a fan connected to a breadboard with a mosfet pin and a potentiometer—many wires connecting the individual parts.

Initial wiring of Arduino, mosfet pin, potentiometer and fan

Set up showing a blank blue screen of an LCD display connected to an Arduino and the rest of the breadboard. May wires going around.

Troubleshooting LCD Display (was not displaying)

View of a working LCD display, and behind, the original setup of our double transducer with wind sensor, fan, and Arduino clearly in frame, attached with breadboard with many wires.

Troubleshooting LCD Display (incorrect format and placement)

View of two red breadboards that are in the process of soldering, with wires coming out of them. Hands with blue gloves holding the parts.

In-progressing soldering

Discussion

During our first project, we created a double transducer that would use rotation from a potentiometer as an input and servo motor as our output. Other project components included an LCD, fan, wind sensor, and servo motor. One relatively easy aspect was the initial setup and connection of the individual components to the Arduino board and the breadboard. From doing the homework and taking advantage of reviewing IDE-provided sketches, we established our basic framework quickly. Creating the block diagram and schematics was a relatively simple process when we had our idea finalized. We first built one model together, and after the base components worked, we proceeded to make a more organized copy of our project, taking time to ensure that all the wiring was correct. 

However, as we delved more into the project, synchronizing and mapping the interactions between each component presented us with multiple challenges. It seemed as though after debugging one aspect of our code, new problems would surface. An example of this would be the servo motor and the wind sensor. Both were mapped incorrectly, and it wouldn't function properly, for some reason, when the LCD was attached. After meeting with the TA, we could map each component correctly. One thing that we found particularly helpful was to debug each element one by one using the example sketches from the library. Using this method was even valuable during the demo day when our projects did not seem to work (one ended up not working due to a software or hardware issue). As we tested the software for the LCD and fan, we realized that both wirings were wrong, and we successfully fixed this issue before having to demonstrate it in class. 

Because this project was highly technical, it allowed us to have experience in applying our base knowledge of Arduino to new inputs and outputs. We learned the technicalities of programming in alignment with the components we used and how they impacted one another. The challenges we continually faced allowed us to reflect on our processes and emphasize the value of testing and retesting and how fussy the relationship between software and hardware is!

Functional block diagram and electrical schematic

Code

/*

    Double Transducer: Rotation-for-Force structure sketch


    Demonstrates how to structure an Arduino sketch so that

    the loop contains four basic elements:

      1) read inputs (gather information from the world)

      2) compute and make decisions based on those inputs

      3) drive outputs (effect different actuators in the world)

      4) report information back to the user


    While not every interactive device necessarily needs all

    four of these steps in the loop, many often do.


    For the purpose of this demonstration sketch, this code

    is written for a device that will read a potentiometer as an

    input and drive a servo motor as an output. When the potentimoter is turned, the fan's speed is increased.

    The wind created by the fan is read by a wind sensor so that as wind increases,

    the servo motors will increase its rotatation to exert force.


    Pin mapping:


    Arduino pin | role  | details

    ------------------------------

    A0             input   potentiometer

    11            output   mosfetpin

    A1             input   wind sensor

    9              output  servo motor



    Released to the public domain by the authors, Febuary 2024

    Audrey Reiley, areiley@andrew.cmu.edu

    Brandt Li youranl@andrew.cmu.edu


*/


#include <Wire.h> //library to send and recieve information

#include <LiquidCrystal_I2C.h> //library for LCD display

#include <Servo.h> //Library for Servo Motor


// I2C address of the LCD. Most 16x2 LCDs use 0x27 or 0x3F

LiquidCrystal_I2C lcd(0x27, 16, 2);


const int potentiometerPin = A0;           // Analog input for potentiometer

const int mosfetPin = 11;                  // Digital output for MOSFET control

const int windSensorOutPin = A1;           // Analog input for wind sensor

const int SERVOPIN = 9;                    // Define the servo motor pin

Servo myServo;                             // Servo motor control


void setup() {

  Serial.begin(9600);                      // Start Serial communication at 9600 baud

  myServo.attach(SERVOPIN);                 // Attach the servo to the defined pin (SERVOPIN)

 

  // Initialize the LCD

  lcd.init();

  lcd.backlight();                         // Turn on the backlight of the LCD

}


void loop() {

  // Step 1: Sense

  int potValue = analogRead(potentiometerPin);  // Read the analog value from the potentiometer

  int windOutValue = analogRead(windSensorOutPin); // Read the analog value from the wind sensor (received help from TA's Angie and Virshal Urlam)


  // Step 2: Compute

  int fanSpeed = map(potValue, 0, 1023, 0, 255); // Map the potentiometer value to the fan speed range (0-255)

  int servoPosition = map(windOutValue, 270, 480, 0, 180); // Map wind sensor value to servo position


  // Step 3: Drive outputs

  analogWrite(mosfetPin, fanSpeed);              // Set the MOSFET output to control the fan speed

  myServo.write(servoPosition);                    // Set the servo position based on the wind sensor value (received help from TA's Angie and Virshal Urlam)


  // Step 4: Report back data

  Serial.println(windOutValue);                     // Print the wind sensor value to Serial monitor

 

  // Update the LCD with the new values

  lcd.clear();                             // Clear the LCD screen


  // Display potentiometer value and fan speed on LCD

  lcd.setCursor(0, 0);                     // Set cursor to the top left

  lcd.print("i=");


  // Map and print the potentiometer value in the range 0-100

  int potValuenew = map(potValue, 0, 1023, 0, 100);

  Serial.println(potValuenew);

  lcd.print(potValuenew);

 

  lcd.setCursor(5, 0);                     // Move to the top center

  lcd.print("m=");


  // Map and print the fan speed in the range 0-100

  int fanSpeednew = map(fanSpeed, 0, 255, 0, 100);

  lcd.print(fanSpeednew);


  // Display wind sensor output on LCD

  lcd.setCursor(7, 1);                     // Move to the bottom left

  //lcd.print("Wind=");

 

  // Map and print the wind sensor value in the range 0-100

  int windOutValuenew = map(windOutValue, 270, 600, 0, 100);

  lcd.print(windOutValuenew);


  // Display servo position on LCD

  lcd.setCursor(12, 1);                    // Move to the bottom center

  lcd.print("o=");

  Serial.println(servoPosition);


  // Map and print the servo position in the range 0-100

  int servoPositionnew = map(servoPosition, 0, 255, 0, 100);

  lcd.print(servoPositionnew);


  delay(300);                              // Update every 300 milliseconds

}