First off, I'm new to all of this. I tinker a lot. Just trying to get a simple communication script setup with my Raspberry Pi 4 and Teensy 3.2
Right now, I want to run a python script that will set a GPIO pin high or low - Pin is attached to my Teensy 3.2 board. I've attached Pin 12 on the Pi to Pin 2 on the Teensy. Nothing happens when the Python script is running.
Python Script
Teensy Code
Right now, I want to run a python script that will set a GPIO pin high or low - Pin is attached to my Teensy 3.2 board. I've attached Pin 12 on the Pi to Pin 2 on the Teensy. Nothing happens when the Python script is running.
Python Script
Code:
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.output(12, GPIO.HIGH)
print("Pin 12 = HIGH")
time.sleep(5)
GPIO.output(12, GPIO.LOW)
print("Pin 12 = LOW")
time.sleep(5)
GPIO.output(12, GPIO.HIGH)
print("Pin 12 = HIGH")
time.sleep(5)
GPIO.output(12, GPIO.LOW)
print("Pin 12 = LOW")
time.sleep(5)
print("This is the end of the script")
time.sleep(5)
GPIO.cleanup()
Teensy Code
Code:
int ledPin = 13;
int buttonPin = 2;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, buttonState);
}