Переглянути джерело

'Beispiel_ecg_read.py' hinzufügen

maxscheinast 7 місяців тому
батько
коміт
685dc33c94
1 змінених файлів з 39 додано та 0 видалено
  1. 39 0
      Beispiel_ecg_read.py

+ 39 - 0
Beispiel_ecg_read.py

@@ -0,0 +1,39 @@
+import time
+from machine import Pin, UART, ADC
+
+# Pin Definitions (Assuming these are correct)
+output_pin = machine.Pin(26, machine.Pin.IN)
+lo_minus_pin = machine.Pin(27, machine.Pin.IN)
+lo_plus_pin = machine.Pin(8, machine.Pin.IN)
+
+# Configure ADC
+adc = ADC(output_pin)
+print("version_1")
+# Function to map ADC value to desired range
+def map_value(value, in_min, in_max, out_min, out_max):
+    return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
+
+# Function to read and process ECG signal
+def read_ecg():
+    adc_value = adc.read_u16()
+    signal = map_value(adc_value, 0, 65535, 0, 100)  # Example mapping
+    return signal
+
+# Configure UART for 11520 baud rate
+#uart = UART(0, baudrate=11520, tx=Pin(0), rx=Pin(1))  # Adjust pins as needed
+k=0
+while True:
+    
+    printlist=[]
+    for i in range(100):
+        ecg_signal = read_ecg()
+        printlist.append(ecg_signal)
+    # Transmit the ECG signal
+    #uart.write(str(ecg_signal) + "\n")  # Send data with newline character
+    for ecg_signal in printlist:
+        #k=k+1
+        #print(k)
+        print(ecg_signal)
+    # Optional delay between readings
+    #time.sleep(0.00001)  # Adjust delay as needed
+