Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. time = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
  2. voltage = [0,1,1,0,1,1,0,0,1,1,0,1,1,0,1,1]
  3.  
  4. i = 0
  5.  
  6. for i in range(1, len(time)):
  7.     if voltage[i-1] - voltage[i] == 0:
  8.         continue
  9.  
  10.     if voltage[i-1] - voltage[i] == -1:
  11.         time_start = i  # pulse has started again
  12.  
  13.     if voltage[i-1] - voltage[i] == 1:
  14.         time_end = i  # pulse has ended
  15.  
  16. time_period = time_start - time_end
  17.  
  18. print(time_end)
  19. print(time_start)
  20. print(time_period)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement