Am I able to connect two arduinos so that one takes the input of an ultrasonic sensor and the other uses that reading to turn on a gearmotor? I’ve been looking into master/slave code but none with what I need so whenever I modify it it stops working.
Yes you can. As you mentioned in your question, you have to use two HC-05 bluetooth modules connected to the arduinos. And configure the modules as master and slave.
Two Arduinos have several ways of easily communicating with each other.
- connect them using the Serial port, TX of one attached to RX of the other and vice-versa. Simple to program a protocol. 2 wires, no extra hardware.
- connect them using I2C. This is bit more complicated to program if there is no fixed master and slave device. 2 wires, no extra hardware.
- connect them using SPI. Again, the protocol is a bit complicated but there are examples out there. 3 wires, no extra hardware
- connect them with WiFi or Bluetooth. Requires breakout boards and a bit of programming
- connect them with your own protocol. Requires no extra hardware but at least 2 wires, depending upon how you program