mirror of
https://github.com/ft-NotArt/ShyEye.git
synced 2025-10-29 20:35:59 +00:00
+ | Serial tests
This commit is contained in:
parent
0529be0cd1
commit
e3ab5fe8dc
12
Serial_test/Serial_test.ino
Normal file
12
Serial_test/Serial_test.ino
Normal 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
14
Serial_test/serialTest.py
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user