+ | Serial tests

This commit is contained in:
NotArt 2025-03-07 05:33:11 +01:00
parent 0529be0cd1
commit e3ab5fe8dc
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,12 @@
int x;
void setup() {
Serial.begin(9600);
Serial.setTimeout(1);
}
void loop() {
while (!Serial.available());
x = Serial.readString().toInt();
Serial.print(x + 1);
}

14
Serial_test/serialTest.py Normal file
View File

@ -0,0 +1,14 @@
# Importing Libraries
import serial
import time
arduino = serial.Serial(port='/dev/ttyACM0', baudrate=9600, timeout=.1)
def write_read(x):
arduino.write(bytes(x, 'utf-8'))
time.sleep(0.05)
data = arduino.readline()
return data
while True:
num = input("Enter a number: ") # Taking input from user
value = write_read(num)
print(value) # printing the value