Python Forum
Getting error in finding time.time() value in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting error in finding time.time() value in python
#1
while True:

    Signal=mcp.read_adc(adc_number)  # The read_adc function will get the value of the specified channel and the Signal will hold the incoming raw digital data
    if(Signal>thresh) and (i<=5):
        if i==0:
            time1=int(time.time()*1000)
        c=c+1
        i=i+1
        time2=int(time.time()*1000)
    t=time2-time1
    rate=t/5
    rate=60000/rate
    print(rate) # BPM
    time.sleep(0.005)
I wrote this program for measuring the beats/minute(BPM) from a pulse sensor. This code shows an error like time2 and time1 not defined. Is this code correct for finding the BPM value from pulse sensor?
Reply
#2
Both time1 and time2 are in if condition block of code. If the condition is False they will not be created.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Date Time Series Help...Please spra8560 2 313 Feb-01-2024, 01:38 PM
Last Post: spra8560
  Python date format changes to date & time 1418 4 518 Jan-20-2024, 04:45 AM
Last Post: 1418
  time difference bettwenn logs enkliy 14 876 Nov-21-2023, 04:51 PM
Last Post: rob101
Question Need Help with Vehicle Routing Problem with Time Windows (VRPTW) in Python kasper321421312 1 506 Nov-10-2023, 08:19 PM
Last Post: snippsat
  How do I stream and record at the same time with arducam? traderjoe 0 430 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 506 Oct-03-2023, 11:15 AM
Last Post: snippsat
  Error is finding mean of a list PythonBoy 4 844 Sep-11-2023, 02:38 PM
Last Post: PythonBoy
  [Python 2.7] Why can't I press [ESC] a fourth time? Ashwood 3 621 Aug-27-2023, 02:01 PM
Last Post: deanhystad
  Hard time trying to figure out the difference between two strings carecavoador 2 644 Aug-16-2023, 04:53 PM
Last Post: carecavoador
  return next item each time a function is executed User3000 19 2,175 Aug-06-2023, 02:29 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020