@@ -21,6 +21,10 @@ Arduino_Robot_Firmware::Arduino_Robot_Firmware(){
2121
2222 // color sensor
2323 apds9960 = new APDS9960 (*wire,APDS_INT);
24+
25+ // servo
26+ servo_A = new Servo ();
27+ servo_B = new Servo ();
2428}
2529
2630int Arduino_Robot_Firmware::begin (){
@@ -44,6 +48,9 @@ int Arduino_Robot_Firmware::begin(){
4448 wire->begin ();
4549
4650 beginAPDS ();
51+ beginServo ();
52+ beginI2Cselect ();
53+ connectExternalI2C ();
4754
4855 return 0 ;
4956}
@@ -97,4 +104,42 @@ int Arduino_Robot_Firmware::getBlue(){
97104
98105int Arduino_Robot_Firmware::getProximity (){
99106 return bottom_proximity;
107+ }
108+
109+ /* *****************************************************************************************************/
110+ /* RC Servo A & B */
111+ /* *****************************************************************************************************/
112+
113+ int Arduino_Robot_Firmware::beginServo (){
114+ servo_A->attach (SERVO_A);
115+ servo_B->attach (SERVO_B);
116+ return 0 ;
117+ }
118+
119+ void Arduino_Robot_Firmware::setServoA (int position){
120+ servo_A->write (position);
121+ }
122+
123+ void Arduino_Robot_Firmware::setServoB (int position){
124+ servo_B->write (position);
125+ }
126+
127+ /* *****************************************************************************************************/
128+ /* RC Servo A & B */
129+ /* *****************************************************************************************************/
130+
131+ int Arduino_Robot_Firmware::beginI2Cselect (){
132+ pinMode (SELECT_I2C_BUS,OUTPUT);
133+ }
134+
135+ void Arduino_Robot_Firmware::setExternalI2C (uint8_t state){
136+ digitalWrite (SELECT_I2C_BUS,state);
137+ }
138+
139+ void Arduino_Robot_Firmware::connectExternalI2C (){
140+ setExternalI2C (LOW);
141+ }
142+
143+ void Arduino_Robot_Firmware::disconnectExternalI2C (){
144+ setExternalI2C (HIGH);
100145}
0 commit comments