In our double transducer project, we took a light as input, transduced it to to a motor which affected a read of tilt. The tilt was then transduced once more to the rotational speed of a stepper motor output.
TinkerCad Circuit
Physical Overview
Project Video
Notable Details
Simple Narrative Description
This project is a double transducer that converts light intensity into tilt which is then translated into rotational intensity. We use an LED which is connected to a potentiometer to vary the brightness of the LED, which is then read by a photoresistor. The photoresistor reading is then sent to a servo motor, whose angle is adjusted based on the input it gets. The accelerometer is attached to the servo and hence it also rotates with the servo, providing different tilt readings. These readings are then mapped to a stepper motor, whose rotation speed varies based on its input.
Progress Images
Discussion
When we began working on this project, it sounded a lot more straightforward than it turned out to be. The light intensity step was quite easy and done very quickly. We did have a slight challenge with getting a large range of readings from the photoresistor, probably because the LED is not very bright and the background light contributes to a big part of the photoresistor’s reading. However, by adjusting the range of values from which the photoresistor readings are mapped to servo motor readings, we overcame the issue of very small angle change due to small change in photoresistor readings.
The second main issue we faced was that the Servo motor and the stepper motor both would not function at the same time, and if they did, they wouldn’t function smoothly or properly. We later, after help from the professor, realized that this was due to a large amount of power consumption by the stepper motor, which doesn’t allow the two of them to function well together. However, we were unable to fix that error as we diagnosed the problem during the project presentation. In order to slightly improve the functioning of the two motors, we used the same trick as we used for the photoresistor, we mapped a smaller range of tilt values to a much larger range of stepper motor rotation speeds so that small incremental changes would still look bigger.
Overall, there was a lot we learned through this project. One of the main things was that physical parts don’t always work like they are supposed to. We don’t get readings as clearly and easily as we get through a simulation. It also made us realize how much more time it takes to make it work. In general, we went from knowing how to build a very basic circuit to a decently complicated double transducer through this project.
Schematic
Code
/* * Tilt Tranducer - Light -> Rotational Intensity * * Connor McGaffin (cmcgaffi) & Sruti Srinidhi (ssrinidh) * * Description: The code below takes the readings from a photoresistor and maps * it to an angle to which the servo motor rotates. As the servo motor rotates, * the accelerometer rotates as well and the code reads the accelerometer * readings and maps it to a rotational speed for the stepper motor, which * ultimately changes the rotational intensity. * * Pin mapping: * * pin | mode | description * ------|--------|------------ * 2 input lcd * 3 output servo motor * 4 input lcd * 5 input lcd * 6 output stepper motor * 7 output stepper motor * 8 output stepper motor * 9 output stepper motor * 10 input lcd * 11 output LED output * 12 input lcd * 13 input lcd * A0 input Accelerometer x-axis value * A1 input Accelerometer y-axis value * A2 input Accelerometer z-axis value * A5 input Photoresistor value * */ #include <Stepper.h> #include <Servo.h> #include <LiquidCrystal.h> // Number of steps per revolution and step count for stepper motor const int stepsPerRevolution = 200; int stepCount = 0; // initialize motors and LCD objects and their pins Stepper myStepper(stepsPerRevolution, 6,7,8,9); Servo tiltMotor; LiquidCrystal lcd(13, 12, 10, 5, 4, 2); //Initialize pin constants const int xPin = A0; const int yPin = A1; const int zPin = A2; const int LEDPIN = 11; const int PHOTOPIN = A5; const int SERVOTILTPIN = 3; unsigned long timer = 0; int photoVal; void setup() { pinMode(LEDPIN, OUTPUT); pinMode(yPin, INPUT); pinMode(PHOTOPIN, INPUT); tiltMotor.attach(SERVOTILTPIN); lcd.begin(16, 2); Serial.begin(115200); Serial.setTimeout(50); } void loop() { int tiltAngle; int yPinVal; // Light write and read digitalWrite(LEDPIN,HIGH); photoVal = analogRead(PHOTOPIN); //Convert to angle of servo motor tiltAngle = map(photoVal, 500, 1000, 0, 180); tiltMotor.write(tiltAngle); //Read accelerometer yPinVal = analogRead(yPin); //Change rotational intensity of stepper motor int motorSpeed = map(yPinVal, 200, 1023, 0, 100); if (motorSpeed > 0) { myStepper.setSpeed(motorSpeed); myStepper.step(stepsPerRevolution / 100); } //Output details on LCD lcd.setCursor(0, 0); lcd.print("i:"); lcd.setCursor(2,0); lcd.print(map(photoVal,0,1023,100,0)); lcd.setCursor(5,0); lcd.print("m:"); lcd.setCursor(7,0); lcd.print(map(tiltAngle, 0, 180, 0 ,100)); lcd.setCursor(7,1); lcd.print(map(yPinVal, 300, 600, 0 ,100)); lcd.setCursor(10,1); lcd.print("o:"); lcd.setCursor(12,1); lcd.print(motorSpeed); delay(15); }