Every day is a school day. No matter your age, every day has an opportunity to learn something new. Enjoying trying new things, learning new skills and making something fun.
This is a variation of the timer that can be used for Bar Billiards table, or anything else where you want to have a variable timer that can control a relay. This does not directly operate a servo, but just control operation of a relay that can then operate a solenoid or linear actuator etc for the bar drop.
The advange here is this cheap board contains an integrated display that can be used to visually see the time limit set and time remaining. Also has a built in wifi module which in this case is not being used.
There are many different fonts available to use and have a few included in the basic script to try.
const int relayPin = 16; // Pin for triggering relay. Labeled D0 on board
const int potPin = A0; // Analog pin for variable resistor
const int buttonPin = 5; //timer reset Labeled D1 on board
unsigned long timerStart = 0;
unsigned long waitTime = 60000; // Default to 1 minute
unsigned long lastUpdate = 0;
bool buttonPressed = false;
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT); // Set relay pin as output
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
u8g2.begin();
// u8g2.setFont(u8g2_font_ncenB10_tr);
// u8g2.setFont(u8g2_font_cupcakemetoyourleader_tr);
//u8g2.setFont(u8g2_font_sticker_mel_tr);
u8g2.setFont(u8g2_font_pixelmordred_tr);
waitTime = map(analogRead(potPin), 0, 1023, 60000, 1200000);
Serial.print("Timer set to : ");
Serial.print(waitTime);
timerStart = millis();
digitalWrite(relayPin, LOW); // Relay OFF
}
void loop() {
// Only update once per second
if (millis() - lastUpdate >= 1000) {
lastUpdate = millis();
// Read potentiometer and map it to 1-20 minutes
// Calculate remaining time
unsigned long elapsedTime = millis() - timerStart;
if (elapsedTime >= waitTime) {
elapsedTime = waitTime; // Clamp to 0
digitalWrite(relayPin, HIGH); // Relay ON
}
unsigned long remainingTime = waitTime - elapsedTime;
unsigned int minutes = remainingTime / 60000;
unsigned int seconds = (remainingTime % 60000) / 1000;
This is for a basic timer that can be made cheaply for use on a Bar Billiards table. It uses a cheap Arduino Uno board and can be connected directly to a small server to control the bar. Alternatively the output from pin 8 can be used to trigger a relay to control more powerful devices such as a solenoid or linear actuator.
Servo myServo;
const int buttonPin = 2;
const int servoPin = 9;
const int relayPin = 8; // Pin for triggering relay
const int potPin = A0; // Analog pin for variable resistor
bool buttonPressed = false;
unsigned long timerStart = 0;
unsigned long waitTime = 60000; // Default to 1 minute
void setup() {
myServo.attach(servoPin);
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
pinMode(relayPin, OUTPUT); // Set relay pin as output
myServo.write(0); // Start at 0 degrees
digitalWrite(relayPin, HIGH); // Relay ON when at 0 degrees
timerStart = millis(); // Start the timer
}
void loop() {
// Read potentiometer value and map it to time (1 min to 20 min in 1-min steps)
waitTime = map(analogRead(potPin), 0, 1023, 60000, 1200000); // Map to 60,000 - 1,200,000 ms
// Wait for the adjusted time before moving to 90 degrees
if (!buttonPressed && millis() - timerStart >= waitTime) {
myServo.write(90); // Move to 90 degrees
digitalWrite(relayPin, LOW); // Relay OFF when at 90 degrees
}
// Check if button is pressed
if (digitalRead(buttonPin) == LOW) {
buttonPressed = true;
myServo.write(0); // Move back to 0 degrees
digitalWrite(relayPin, HIGH); // Relay ON when at 0 degrees
timerStart = millis(); // Reset the timer
while (digitalRead(buttonPin) == LOW); // Wait for button release
buttonPressed = false;
}
}
Good day, I am looking for information regarding variations for Bar Billiards tables and appreciate any information on them as they are pretty scarce in Japan.
The point values for our table have been done according to the below assignment. But are aware of at least one variation that has the top row as 10, 20, 30, 20, 10
Does anyone have any more? What size are the balls being used on your table? Just red & white or any other colour combinations? How wide are the ball return lanes in the table?
Dale Chan-nel
Basic Timer with ESP8266
This is a variation of the timer that can be used for Bar Billiards table, or anything else where you want to have a variable timer that can control a relay. This does not directly operate a servo, but just control operation of a relay that can then operate a solenoid or linear actuator etc for the bar drop.
The advange here is this cheap board contains an integrated display that can be used to visually see the time limit set and time remaining. Also has a built in wifi module which in this case is not being used.
There are many different fonts available to use and have a few included in the basic script to try.
Available from Amazon.
amzn.to/4jsnR73
Arduino Script.
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 12, U8X8_PIN_NONE); // oled display
const int relayPin = 16; // Pin for triggering relay. Labeled D0 on board
const int potPin = A0; // Analog pin for variable resistor
const int buttonPin = 5; //timer reset Labeled D1 on board
unsigned long timerStart = 0;
unsigned long waitTime = 60000; // Default to 1 minute
unsigned long lastUpdate = 0;
bool buttonPressed = false;
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT); // Set relay pin as output
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
u8g2.begin();
// u8g2.setFont(u8g2_font_ncenB10_tr);
// u8g2.setFont(u8g2_font_cupcakemetoyourleader_tr);
//u8g2.setFont(u8g2_font_sticker_mel_tr);
u8g2.setFont(u8g2_font_pixelmordred_tr);
waitTime = map(analogRead(potPin), 0, 1023, 60000, 1200000);
Serial.print("Timer set to : ");
Serial.print(waitTime);
timerStart = millis();
digitalWrite(relayPin, LOW); // Relay OFF
}
void loop() {
// Only update once per second
if (millis() - lastUpdate >= 1000) {
lastUpdate = millis();
// Read potentiometer and map it to 1-20 minutes
// Calculate remaining time
unsigned long elapsedTime = millis() - timerStart;
if (elapsedTime >= waitTime) {
elapsedTime = waitTime; // Clamp to 0
digitalWrite(relayPin, HIGH); // Relay ON
}
unsigned long remainingTime = waitTime - elapsedTime;
unsigned int minutes = remainingTime / 60000;
unsigned int seconds = (remainingTime % 60000) / 1000;
// Display
u8g2.firstPage();
do {
waitTime = map(analogRead(potPin), 0, 1023, 60000, 1200000);
u8g2.setCursor(0, 12);
u8g2.print(F("Limit: "));
u8g2.print(waitTime / 60000);
u8g2.print(F(" mins"));
u8g2.setCursor(0, 36);
u8g2.print(F("Remaining:"));
char timeStr[10];
sprintf(timeStr, "%02u:%02u", minutes, seconds);
u8g2.setCursor(0, 60);
u8g2.print(timeStr);
} while (u8g2.nextPage());
}
if (digitalRead(buttonPin) == LOW) {
buttonPressed = true;
digitalWrite(relayPin, LOW); // Relay OFF
timerStart = millis(); // Reset the timer
while (digitalRead(buttonPin) == LOW); // Wait for button release
buttonPressed = false;
}
}
6 months ago | [YT] | 0
View 0 replies
Dale Chan-nel
Basic Bar Billiards Timer
This is for a basic timer that can be made cheaply for use on a Bar Billiards table.
It uses a cheap Arduino Uno board and can be connected directly to a small server to control the bar.
Alternatively the output from pin 8 can be used to trigger a relay to control more powerful devices such as a solenoid or linear actuator.
Arduino code.
#include <Servo.h>
Servo myServo;
const int buttonPin = 2;
const int servoPin = 9;
const int relayPin = 8; // Pin for triggering relay
const int potPin = A0; // Analog pin for variable resistor
bool buttonPressed = false;
unsigned long timerStart = 0;
unsigned long waitTime = 60000; // Default to 1 minute
void setup() {
myServo.attach(servoPin);
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
pinMode(relayPin, OUTPUT); // Set relay pin as output
myServo.write(0); // Start at 0 degrees
digitalWrite(relayPin, HIGH); // Relay ON when at 0 degrees
timerStart = millis(); // Start the timer
}
void loop() {
// Read potentiometer value and map it to time (1 min to 20 min in 1-min steps)
waitTime = map(analogRead(potPin), 0, 1023, 60000, 1200000); // Map to 60,000 - 1,200,000 ms
// Wait for the adjusted time before moving to 90 degrees
if (!buttonPressed && millis() - timerStart >= waitTime) {
myServo.write(90); // Move to 90 degrees
digitalWrite(relayPin, LOW); // Relay OFF when at 90 degrees
}
// Check if button is pressed
if (digitalRead(buttonPin) == LOW) {
buttonPressed = true;
myServo.write(0); // Move back to 0 degrees
digitalWrite(relayPin, HIGH); // Relay ON when at 0 degrees
timerStart = millis(); // Reset the timer
while (digitalRead(buttonPin) == LOW); // Wait for button release
buttonPressed = false;
}
}
7 months ago | [YT] | 0
View 0 replies
Dale Chan-nel
Bar Billiards Variations
Good day,
I am looking for information regarding variations for Bar Billiards tables and appreciate any information on them as they are pretty scarce in Japan.
The point values for our table have been done according to the below assignment. But are aware of at least one variation that has the top row as 10, 20, 30, 20, 10
Does anyone have any more?
What size are the balls being used on your table? Just red & white or any other colour combinations?
How wide are the ball return lanes in the table?
Any information will be a great help.
7 months ago | [YT] | 0
View 0 replies