Skip to content

Instantly share code, notes, and snippets.

@mraza007
Created June 27, 2019 19:40
Show Gist options
  • Save mraza007/2ff74c692e7d99445098a7b33821ae01 to your computer and use it in GitHub Desktop.
Save mraza007/2ff74c692e7d99445098a7b33821ae01 to your computer and use it in GitHub Desktop.
#RPi Pinouts
#I2C Pins
#GPIO2 -> SDA
#GPIO3 -> SCL
#Import the Library Requreid
import smbus
import time
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)
# This is the address we setup in the Arduino Program
#Slave Address 1
address = 0x66
#Slave Address 2
address_2 = 0x66
def writeNumber(value):
bus.write_byte(address, value)
bus.write_byte(address_2, value)
# bus.write_byte_data(address, 0, value)
return -1
def readNumber():
# number = bus.read_byte(address)
number = bus.read_byte_data(address, 1)
return number
while True:
#Receives the data from the User
data = input("Enter the data to be sent : ")
data_list = list(data)
for i in data_list:
#Sends to the Slaves
writeNumber(int(ord(i)))
time.sleep(.1)
writeNumber(int(0x0A))
#End of the Script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment