Tuesday, November 29, 2016

RPM to MPH for Accelorometer

 #Accelrometer RPM to MPH
 #Rahul Manoharan
 #11/17/2016

import smbus
import time


bus = smbus.SMBus(1)


 # This is the address we setup in the Arduino Program
address = 0x08


def writeNumber(value):
     bus.write_byte(address, value)
     return -1


def redNumber():
     number = bus.read_byte(address)
     return number


while True:
     var = input("enter a number:")
     writeNumber(var)
     print ("RPI: Hi Arduino, I sent you "), var
     time.sleep(1)

     #number is rpm number
     number = readNumber()
     print ("Arduino: Here's the current RPM: "), number
     
    #conversion equation
     MPH = ( (4.5 * number) * 60) / 63360
     print ("Here's the current MPH: "), MPH

No comments:

Post a Comment