This experiment is divided into two parts: one is control and another is feedback control, thus, testing Lego Motor with application on iPad is extremely important for control part. This is the basic of this experiment.
We refer the article "iOS Sensor Apps with Arduino" to develop the Apple software to control the Lego motor. The interface of software is shown in Figure 1:
Figure 1: Software Interface on iPad
Each switch is off initially, and when we press it, and then it will be opened. When it opened, the corresponding signal will be transferred from iPad to Arduino board via Redpark Serial Cable as shown in Figure 2. The transferred information is shown in following Figure 3:
Figure 2: Redpark Serial Cable
Figure 3: Transmitted information via Redpark Serial Cable
When we switch the button, two-byte message will be transmitted from iPad to Arduino board. The first byte will indicate the pin number and the second pin will be 0 or 1 which is the state of the switch (on/off). If the switch is on, the corresponding pin is HIGH, otherwise, the pin is LOW.
After that, connect iPad to Arduino board, and then upload the corresponding the program to Arduino board.
Note: The receive (RX) pin (pin0) in Arduino is connected to the transmission (TX) pin in the adopter. The transmission (TX) pin (pin1) in Arduino is connected to the receive (RX) line in the adopter. The ground (GND) pin is connected with each other.
Finally, we will test Lego Motor with iOS application. Before that, we need to connect the power supply board to Lego Motor and Arduino board. When we turn on the corresponding switches, the motor will rotate forward or backward. In this test, we only test the above motor. Pin 9 and Pin 11 will control this motor as shown in Figure 4 and 5.
Figure 4: Pin 9 is on, Pin 11 is off, rotate forward
Figure 5: Pin 9 is off, Pin 11 is on, rotate backward