The Automatic Golf Tee System is designed to automate the process of raising a golf ball to a desired height on a tee using a Raspberry Pi Pico microcontroller. The system utilizes a PIR sensor to detect the presence of a golf ball, pushbuttons to control the height adjustment, an H-bridge motor driver to control a linear actuator, and a power supply system consisting of a 12V power supply and a buck converter to provide the necessary voltages for the components.
pin 1
connected to PIR sensor signal output (SIG)pin 3
, pin 4
, pin 5
, pin 6
connected to pushbutton pins 1 and 3 (common connections for all pushbuttons)pin 27
connected to H-bridge motor driver enable pin (EN (A))pin 31
connected to H-bridge motor driver input 2 (IN2 (A))pin 32
connected to H-bridge motor driver input 1 (IN1 (A))pin 34
connected to linear actuator potentiometer signal output (2. Signal: Wiper)pin 36
connected to PIR sensor VDD and linear actuator logic voltage (1. Vcc)pin 37
connected to buck converter output positive (OUT+)pin 38
connected to common ground for PIR sensor, linear actuator potentiometer ground, and buck converter output negative (OUT-)VDD
connected to Raspberry Pi Pico pin 36
and linear actuator logic voltageSIG
connected to Raspberry Pi Pico pin 1
GND
connected to common groundPin 1
of all pushbuttons connected together and to Raspberry Pi Pico pin 3
Pin 3
of each pushbutton connected to Raspberry Pi Pico pin 4
, pin 5
, and pin 6
respectivelyEN (A)
connected to Raspberry Pi Pico pin 27
IN2 (A)
connected to Raspberry Pi Pico pin 31
IN1 (A)
connected to Raspberry Pi Pico pin 32
GND
connected to common groundMotor V+
connected to linear actuator motor power supply +12V and buck converter input positive (IN+)+12V - actuator motor power supply +12V
connected to H-bridge motor driver Motor V+
and buck converter input positive (IN+)GND - actuator motor power supply ground
connected to common ground3.GND - Potentiometer ground
connected to common ground2. Signal: Wiper - potentiometer signal output
connected to Raspberry Pi Pico pin 34
1. Vcc: Logic voltage for the potentiometer
connected to Raspberry Pi Pico pin 36
+
connected to H-bridge motor driver Motor V+
, linear actuator motor power supply +12V, and buck converter input positive (IN+)-
connected to common groundIN+
connected to 12V power supply +
IN-
connected to common groundOUT+
connected to Raspberry Pi Pico pin 37
OUT-
connected to common ground/*
* Automatic Golf Tee System
*
* This code controls an automatic golf tee system using a Raspberry Pi Pico.
* A presence sensor detects whether a ball is on the tee. If a ball is present,
* a pushbutton allows the tee to raise the ball to a commanded height. An up
* button and a down button can be used to adjust the current height of the tee.
* The height is saved as the starting position for the next time it is raised.
* When the ball is hit and its presence is no longer detected, the tee lowers
* completely until a new ball is loaded. It then waits for the button press to
* raise the tee again.
*/
#include <Servo.h>
const int presenceSensorPin = 1; // PIR sensor signal pin
const int raiseButtonPin = 4; // Pushbutton to raise the tee
const int upButtonPin = 3; // Button to increase the height
const int downButtonPin = 5; // Button to decrease the height
// Define new pins for the H-bridge motor driver
const int motorPin1 = 32; // IN1 on H-bridge
const int motorPin2 = 31; // IN2 on H-bridge
const int enablePin = 27; // ENA on H-bridge (PWM control)
Servo teeServo;
int currentHeight = 0;
const int minHeight = 0;
const int maxHeight = 180;
bool ballPresent = false;
void setup() {
pinMode(presenceSensorPin, INPUT);
pinMode(raiseButtonPin, INPUT_PULLUP);
pinMode(upButtonPin, INPUT_PULLUP);
pinMode(downButtonPin, INPUT_PULLUP);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
// Initialize the linear actuator to the minimum height
setHeight(minHeight);
}
void loop() {
ballPresent = digitalRead(presenceSensorPin) == HIGH;
if (ballPresent) {
if (digitalRead(raiseButtonPin) == LOW) {
setHeight(currentHeight);
}
if (digitalRead(upButtonPin) == LOW) {
if (currentHeight < maxHeight) {
currentHeight += 5;
setHeight(currentHeight);
delay(200); // Debounce delay
}
}
if (digitalRead(downButtonPin) == LOW) {
if (currentHeight > minHeight) {
currentHeight -= 5;
setHeight(currentHeight);
delay(200); // Debounce delay
}
}
} else {
setHeight(minHeight);
}
}
void setHeight(int height) {
// Control the linear actuator to move to the desired height
// This is a placeholder function. You need to implement the actual control logic
// based on your linear actuator's specifications.
// Example: Move forward
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
analogWrite(enablePin, map(height, minHeight, maxHeight, 0, 255));
// Add logic to stop the motor when the desired height is reached
}
This code is responsible for controlling the golf tee system. It reads inputs from the PIR sensor and pushbuttons to adjust the height of the tee using the linear actuator. The setHeight
function is a placeholder and should be implemented according to the specific linear actuator used in the system.