# Intelligent Pottery Wheel Machine Design: Enhancing Pottery Throwing Quality and Efficiency
## 6 Conclusions
// Set the direction (HIGH or LOW)
16. digitalWrite(dirPin, HIGH);
17. // For demonstrating changes in direction and speed
18. delay(200);
19. speed = 100;
20. analogWrite(pwmPin, speed);
21. digitalWrite(dirPin, LOW);
22. delay(200);
23. } 24. Raspberry Pi Code: Use Python libraries such as RPi.GPIO or pigpio to control the PWM signal and orientation. 25. import RPi.GPIO as GPIO
26. from time import sleep
27. pwm_pin = 18 # The PWM signal pins
28. dir_pin = 23 # Direction control pin
29. sleep_pin = 24 # Sleep pin
30. GPIO.setmode(GPIO.BCM)
31. GPIO.output(pwm_pin, GPIO.OUT)
32. GPIO.setup(dir_pin, GPIO.OUT)
33. GPIO.setup(sleep_pin, GPIO.OUT)
34. # Start the drive
35. GPIO.output(sleep_pin, GPIO.HIGH)
36. pwm = GPIO.PWM(pwm_pin, 1000) # PWM was initialized with a frequency at 1 kHz
37. pwm.start(0) # The initial duty cycle is 0%
38. try:
39. while True:
40. # Set the PWM signal duty cycle (0-100)
41. pwm.ChangeDutyCycle(80)
42. # Set the direction (HIGH or LOW)
43. GPIO.output(dir_pin, GPIO.HIGH)

## Appendix C
```
1. #include <Encoder.h>
2. //Encoder Pin
3. Encoder myEnc(2, 3);
4. long targetPosition = 1000; // target location
5. const int pwmPin = 5;
6. const int dirPin = 4;
7. const int sleepPin = 3;
8. //PID variable
9. double kP = 1.0, kI = 0.01, kD = 0.01;
10. void setup() {
11. Serial.begin(9600);
12. pinMode(pwmPin, OUTPUT);
13. pinMode(dirPin, OUTPUT);
14. pinMode(sleepPin, OUTPUT);
15. digitalWrite(sleepPin, HIGH);
16. } 17. void loop() {
18. long newPosition = myEnc.read();
19. double error = targetPosition - newPosition;
20. double output = kP* error;
21. // Prevent excessive output
22. output = constrain(output, -255, 255);
23. // Set the direction
24. if (output >= 0) {
25. digital Write(dir Pin, HIGH);
26. analog Write(pwm Pin, output);
27. } else {
28. Digital Write(dir Pin, LOW);
29. analog Write(pwm Pin, -output);
30. } 31. Serial.print(\"Position: \");
32. Serial.printIn(new Position);
33. delay(100);
34. } ```
**Algorithm A2**_Cont._

## Appendix D
```
1. #include <SoftwareSerial.h>
2. SoftwareSerial <=spSerial(2, 3); // RX, TX
3. void setup() {
4. Serial.begin(115200);
5. esPerSerial.begin(115200);
6. // Reset the ESP8266
7. sendData(\"AT+RST\(\backslash\)r\(\backslash\)n\", 2000, true);
8. // Set up the Wi-Fi mode
9. sendData(\"AT+CWMODE=1\(\backslash\)r\(\backslash\)n\", 1000, true);```
10.//Connect to the Wi-Fi
11.sendData(\"AT+CWJAP=\"SSID\",\"PASSWORD\",\"r\(\backslash\)n\",5000,true);
12.] 13.voidloop(){
14.if(espSerial.available()){
15.Serial.write(espSerial.read));
16.]] 17.if(Serial.available()){
18.espSerial.write(Serial.read));
19.}] 20.} 21.voidsendData(String command,constint timeout,booleandebug){
22.espSerial.print(command);
23.longinttime=mills();
24.while((time+timeout)>mills()){
25.while(espSerial.available()){
26.charc=espSerial.read();
27.if(debug)Serial.print(c);
28.]] 29.}] 30.} ```

**Algorithm A4**_Cont._

## Appendix E

```
1.#include<ESP826 WiFi.h>
2.constchar*sid=\"your_SSID\";
3.constchar*password=\"your_PASSWORD\";
4.voidsetup(){
5.Serial.begin(115200);
6.delay(10);
7.Serial.printIn();
8.Serial.print(\"Connecting to\");
9.Serial.printIn(ssid);
10.WiFi.begin(ssid,password);
11.while(WiFi.status()!=WL_CONNECTED){
12.delay(500);
13.Serial.print(\".\");
14.} 15.Serial.printIn(\"?\");
16.Serial.printIn(\"WiFi connected\");
17.Serial.printIn(\"IP address:\");
18.Serial.printIn(WiFi.localIP0);
19.} 20.voidloop(){
21.//Your main code to communicate
22.} 23.\(\backslash\)Control of the ESP8266 via the Web server
24.cpp
25.#include<ESP8266 WiFi.h>
26.constchar*sid=\"your_SSID\";
27.constchar*password=\"your_PASSWORD\";
28.WiFiServer server(80);
29.voidsetup(){
30.Serial.begin(115200);
31.delay(10);
32.WiFi.begin(ssid,password);
33.while(WiFi.status()!=WL_CONNECTED){
34.delay(500);
35.Serial.print(\".\");
36.}