Hello all,
I am trying to make my arduino mega communicate with my teensy 4.1 through wire1 and lcd print the output. I am using Pins 20 and 21 from arduino mega to Pins 16 and 17 in teensy. Since it is 5v, I pulled up two 1k resistors from 3.3v to the pins 16 and 17. The pins 18 and 19 are used to communicate with my lcd and that is working perfectly fine. As per the pictures, two red wires coming out from the arduino are connected to the right pins and I am a 100% sure about it. The pullup resistors from two 3.3v are from the opposite side where each pairs go to the 16, 17, 18, 19 for both lcd and arduino. I am trying to do a remote startup procedures where I display some kind of data like ("do you want to perform a full calibration sequence?") and the momentary buttons are connected to arduino. Based on the input, I perform some function and tell the teensy again to display the next question from arduino.
I uploaded two codes one for arduino and another for teensy which has been attached to this thread doesn't work and establish communication between them. I need some inputs here to proceed with my project. Please let me know if you all need any additional information.
Also if you all help with which way or idea I can proceed with to perform a set of tasks with the user inputs provided and display the questions via teensy(two buttons connected to arduino) as shown in the last picture, it would be awesome.
Teensy Slave Code:
Arduino Master Code:
I am trying to make my arduino mega communicate with my teensy 4.1 through wire1 and lcd print the output. I am using Pins 20 and 21 from arduino mega to Pins 16 and 17 in teensy. Since it is 5v, I pulled up two 1k resistors from 3.3v to the pins 16 and 17. The pins 18 and 19 are used to communicate with my lcd and that is working perfectly fine. As per the pictures, two red wires coming out from the arduino are connected to the right pins and I am a 100% sure about it. The pullup resistors from two 3.3v are from the opposite side where each pairs go to the 16, 17, 18, 19 for both lcd and arduino. I am trying to do a remote startup procedures where I display some kind of data like ("do you want to perform a full calibration sequence?") and the momentary buttons are connected to arduino. Based on the input, I perform some function and tell the teensy again to display the next question from arduino.
I uploaded two codes one for arduino and another for teensy which has been attached to this thread doesn't work and establish communication between them. I need some inputs here to proceed with my project. Please let me know if you all need any additional information.
Also if you all help with which way or idea I can proceed with to perform a set of tasks with the user inputs provided and display the questions via teensy(two buttons connected to arduino) as shown in the last picture, it would be awesome.
Teensy Slave Code:
Code:
include <Wire.h>
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
Wire1.begin(9); // join i2c bus with address #9
Wire1.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop()
{
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
digitalWrite(led, HIGH); // briefly flash the LED
while(Wire1.available() > 1) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire1.read(); // receive byte as an integer
Serial.println(x); // print the integer
digitalWrite(led, LOW);
}
Arduino Master Code:
Code:
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop() {
Wire.beginTransmission(9); // transmit to device #8
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}