Copy in functioning tests from pi

This commit is contained in:
Kenwood 2021-06-30 00:56:08 +01:00
parent 8fede6107b
commit e8dd3c3fe9
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Raspberry Pi Master for Arduino Slave
# i2c_master_pi.py
# Connects to Arduino via I2C
# DroneBot Workshop 2019
# https://dronebotworkshop.com
from smbus import SMBus
import time
addr = 0x8 # bus address
bus = SMBus(1) # indicates /dev/ic2-1
numb = 1
print ("Enter num")
for _x in range (0, 4):
for i in range(70, 130):
bus.write_byte(addr, i)
time.sleep(0.02)
for i in range(130, 70, -1):
bus.write_byte(addr, i)
time.sleep(0.02)
#while numb == 1:
#
# ledstate = input(">>>> ")
#
# if ledstate == "1":
# bus.write_byte(addr, 0x1) # switch it on
# elif ledstate == "0":
# bus.write_byte(addr, 0x0) # switch it on
# else:
# numb = 0

View File

@ -0,0 +1,12 @@
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(12, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off)
while True: # Run forever
GPIO.output(12, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(12, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second