Advertisement
Cpt_Jellyfish

EEEE4008: ‘Recon-Scout’ Platform: Raspberry Pi (Master) Code

May 13th, 2021
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import numpy as np
  2. from smbus import SMBus
  3. import time
  4. import dropbox
  5.  
  6. #Dropbox setup
  7. token = "" #add dropbox API token here
  8. DBX = dropbox.Dropbox(token)
  9.  
  10. #I2C setup
  11. addr = 0x8
  12. bus = SMBus(1)
  13.  
  14. def routeProcess():
  15.     route = bus.read(address)
  16.    
  17.     #write route to text file
  18.     f = open("maze.txt", "w")
  19.     f.write(route)
  20.     f.close()
  21.    
  22.     #upload text file to Dropbox
  23.     DBX.files_upload(stream.read(), "/maze.txt", mode=dropbox.files.WriteMode.overwrite)
  24.    
  25.     while True:
  26.         #latch
  27.  
  28.  
  29. while True:
  30.     #open and read file
  31.     f = open("flagFile.txt", "r")
  32.     flag = f.read()
  33.  
  34.     #if a symbol is detected
  35.     if flag == "1" or flag == "2":
  36.         bus.write_byte(addr, 0x1)
  37.         routeProcess()
  38.  
  39.     else:
  40.         bus.write_byte(addr, 0x0)
  41.  
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement