I am trying to create a master and slave connection between two arduino and in the tutorial that I am using it states that I have include the <Wire.h> library but when I type it into the search bar in the IDE there is no result. My question is: is there another library that does the same thing or a way to get the library from a different source? Furthermore, will AS3935MI library work? The description states:
Supports I2C and SPI via the Wire and SPI libraries, respectively
Supports I2C and SPI interfaces via other libraries (e.g. Software I2C) by inheritance
Automatic antenna tuning
Be careful when using the I2C bus to communicate between two Arduino boards. You can do that for testing and to learn from. For a real project, you better avoid it, especially when there are motors in the project. The I2C bus is a weak bus, because the high level is created with pullup resistors.
So the reason that I am asking is because I am trying to make the RFID lock and include the screen without using a breadboard, I really just need more slots so that I can wire up the LCD to the system. I dont want to use a breadboard because I wont be able to mount it in the box. My idea was to add the master code in with the RFID code then the slave code to a different arduino so that I can use those connections.
I have 2 years running 8 Nano, 1 master with 7 slaves, almost 3 feet between the master and the furthest slave, without problems (of course there are no motors in the project).
So if I just add a file through the sketch tab and take out the void setup and void loop do you think it will work? How do you make the code work with 2 different sketches on one arduino?
Well, when I tried it I got some error codes:
C:\Users\Anon\OneDrive\Desktop\Arduino Sketches\rfid-2source\FIQF6CLIBL621XX.ino:11:3: error: 'Wire' does not name a type
Wire.begin();
^~~~
C:\Users\Anon\OneDrive\Desktop\Arduino Sketches\rfid-2source\FIQF6CLIBL621XX.ino:12:1: error: expected declaration before '}' token
}
^
exit status 1
Compilation error: 'Wire' does not name a type
Master Code
// Chapter 7 - Communications
// I2C Master
// By Cornel Amariei for Packt Publishing
// Include the required Wire library for I2C
#include <Wire.h>
int x = 0;
// Start the I2C Bus as Master
Wire.begin();
}
Wire.beginTransmission(9); // transmit to device #9
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
x++; // Increment x
if (x > 5) x = 0; // `reset x once it gets 6
delay(500);
}
I was actually able to figure it out after I read a demo on how to run multiple .ino in the same sketch. I have gone a different direction sense then though as even with the master and slave done I didnt really see what i could use it for. I am really new to this and didnt seem like it was useful. What would you use it for?