Hello,
I have a joystick and gimbal combination where a teensy 4.0 board is attached to the joystick for button inputs while the gimbal has a arduino nano (similar) board attached to the gimbal. The teensy has 23 buttons attached to the joystick and I'm trying to figure out how I can get the teensy to talk to the arduino over I2C to take button inputs as well as gimbal inputs from a magnet based x and y sensor. Here is the code for the teensy
I'm trying to get the teensy (slave) to talk to the arduino (master) to hopefully take those inputs and read as a joystick. I haven't really figured out the master code for the arduino as I have been using examples to get going and haven't really gotten far. The code for the teensy basically takes all the inputs from the buttons and prints them as serial data but I haven't been able to get it across to the arduino over i2C.
I posted this question in the aruduino forums and they were pretty much no help.
I have a joystick and gimbal combination where a teensy 4.0 board is attached to the joystick for button inputs while the gimbal has a arduino nano (similar) board attached to the gimbal. The teensy has 23 buttons attached to the joystick and I'm trying to figure out how I can get the teensy to talk to the arduino over I2C to take button inputs as well as gimbal inputs from a magnet based x and y sensor. Here is the code for the teensy
Code:
#include <i2c_device.h>
#include <i2c_driver.h>
#include <i2c_driver_wire.h>
#include "i2c_register_slave.h"
int pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 20, 21, 22, 23, 24, 26};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int i = 0; i < 23; i++){
pinMode(pins[i], INPUT_PULLUP);
Wire.begin(1);
}
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i < 23; i++){
Serial.print(digitalRead(pins[i]));
Serial.print("\t");
}
Serial.println();
delay(5);
}
I'm trying to get the teensy (slave) to talk to the arduino (master) to hopefully take those inputs and read as a joystick. I haven't really figured out the master code for the arduino as I have been using examples to get going and haven't really gotten far. The code for the teensy basically takes all the inputs from the buttons and prints them as serial data but I haven't been able to get it across to the arduino over i2C.
I posted this question in the aruduino forums and they were pretty much no help.