Input Devices¶
Goals¶
Prior Knowledge¶
Projected Timeline¶
- Tuesday (during the week, not before)
- TinkerCAD simulation
- KiCAD
Actual Timeline¶
- Tuesday
Process¶
Planning¶
I more or less already knew the intent of this week, that is, to create a potentiometer system that controls the speed of a servo motor. It must turn 90 degrees at controllable, reasonable speeds before I create a CAD mechanism around it.
TinkerCAD¶
Wiring¶
I found a potentiometer template that I adapted to a servo mechanism. I used a capacitor and transistor to handle the flow of current.
Coding¶
I used the original code for the pinouts and added another pin for the potentiometer. I also included the servo library and used the servo as an object in the system. I embedded the C++ code below.
unsigned long prevTime = 0;
int servoPos = 90;
void loop() {
sensorValue = analogRead(A0);
int delayTime = map(sensorValue, 0, 4095, 100, 2000);
if (millis() - prevTime > delayTime) {
servoPos = (servoPos == 90) ? 0 : 90; // Toggle position
myservo.write(servoPos);
prevTime = millis();
}
Serial.print("Sensor: ");
Serial.print(sensorValue);
Serial.print(" | Delay: ");
Serial.println(delayTime);
}
Wiring Chart¶
Even though I already used the information that ChatGPT provided, now that I had a TinkerCAD simulation, I could make my own list of pinouts. I would transfer these to KiCAD.
-
Potentiometer
- Terminal 1 - GND
- Terminal 2 - 3.3V
- Wiper - A0
-
Resistor (220)
- Terminal 1 - D6
- Terminal 2 - GND
-
Servo
- Power - 5V
- GND - GND
- Signal - D9
KiCAD¶
Components¶
I first added the components required for the circuit to function properly. The TinkerCAD tutorial informed me of these. I also added the No Connect flags and global neighbors to avoid repeating the DRC incident.
Wiring¶
Since I already mapped the connections, I just need to wire accordingly and double-check.
With the potentiometer wiring, I ensured that I was attaching the wiper to the PWM pin, since I almost misplaced the wire by following the terminal numbers. I kept in mind that the wiper in KiCAD has an arrow.
I changed a few connections as well to simplify the layout.
Run DRC¶
The first DRC showed me errors based on the global labels and input pins. I referenced my previous documentation and detached the power symbols from the corresponding pins, which eliminated those errors.