123456789101112131415161718192021222324252627282930313233343536373839 |
- 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
-
|