[Interaction 1] Prototype: Master & Slave Arduino
This blog article will be demonstrating the connection between multiple Arduino. The Arduino that connects with the heartbeat sensor act as the master, while the Arduino that connects with LEDs and the stepper motor act as the slave. I have experimented with multiple sources for the connection, but I will only document the final compiled source that is beneficial. For this project, I have used I2C communication to connect 2 Arduinos.
To summarize, A4, A5 and ground have to connect together to send the signal. As with all I2C sketches, I start by including the Wire library. For the master code, masterWriter() is the main code that send the signals to the slave. Here is the code after include the I2C communication with the sensor sketch:
Master Code
Slave Code
Slave Code integrating with LEDs
I did not screenshot the full sketch as it is just combining the LEDs code from the previous blog into the slave code. RD, in this case, is the BPM of the heart rate.
Slave Code integrating with Stepper Motor
Result
The connection between the master and the slave Arduino (LEDs) :
The connection between the master and the slave Arduino (LEDs + Stepper Motor) :
Hardware Wiring
Conclusion
The connection between the 3 Arduinos are working. However, there are some issues with the stepper motor as it doesn't close when BPM reading = 0. The motor will stop at where it is. Thus, this issue will be looking further in the future for enhancement.
Bibliography
DroneBot Workshop (2019) I2C Part 1 - Using 2 Arduinos. March 31. Available at: LINK
DroneBot Workshop (n.d) I2C Communications Part 1 – Arduino to Arduino. Available at: LINK
Comments
Post a Comment