Skip to content

Commit 69d8d8c

Browse files
committed
fix demo02
1 parent 2882f20 commit 69d8d8c

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

examples/demo_02/demo_02.ino

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ void simpleMotors(){
4242
case 0:
4343
robot.motor_left->setSpeed(4095);
4444
robot.motor_right->setSpeed(4095);
45-
robot.led1->set(HIGH,LOW,LOW);
46-
robot.led2->set(LOW,LOW,HIGH);
47-
if (millis()-tmotor>2000){
45+
robot.setLedLeft(COLOR_BLUE);
46+
robot.setLedRight(COLOR_RED);
47+
if (millis()-tmotor>1000){
4848
status++;
4949
tmotor=millis();
5050
serial.println("forward");
@@ -53,8 +53,8 @@ void simpleMotors(){
5353
case 1:
5454
robot.motor_left->setSpeed(4095);
5555
robot.motor_right->setSpeed(-4095);
56-
robot.led1->set(LOW,LOW,HIGH);
57-
robot.led2->set(HIGH,LOW,LOW);
56+
robot.setLedLeft(COLOR_RED);
57+
robot.setLedRight(COLOR_BLUE);
5858
if (millis()-tmotor>1000){
5959
status++;
6060
status=0;
@@ -67,8 +67,7 @@ void simpleMotors(){
6767
}
6868
robot.motor_left->setSpeed(0);
6969
robot.motor_right->setSpeed(0);
70-
robot.led1->set(LOW,LOW,LOW);
71-
robot.led2->set(LOW,LOW,LOW);
70+
robot.setLeds(COLOR_BLACK);
7271
}
7372

7473
void line_follower(){
@@ -89,17 +88,16 @@ void line_follower(){
8988
serial.println(control);
9089

9190
if ((control<1)&&(control>-1)){
92-
robot.led1->set(LOW,HIGH,LOW);
93-
robot.led2->set(LOW,HIGH,LOW);
91+
robot.setLeds(COLOR_GREEN);
9492
}
9593
else{
9694
if (control>=1){
97-
robot.led1->set(HIGH,HIGH,LOW);
98-
robot.led2->set(LOW,LOW,LOW);
95+
robot.setLedLeft(COLOR_ORANGE);
96+
robot.setLedRight(COLOR_BLACK);
9997
}
10098
else{
101-
robot.led1->set(LOW,LOW,LOW);
102-
robot.led2->set(HIGH,HIGH,LOW);
99+
robot.setLedLeft(COLOR_BLACK);
100+
robot.setLedRight(COLOR_ORANGE);
103101
}
104102
}
105103

@@ -128,6 +126,5 @@ void line_follower(){
128126
}
129127
robot.motor_left->setSpeed(0);
130128
robot.motor_right->setSpeed(0);
131-
robot.led1->set(LOW,LOW,LOW);
132-
robot.led2->set(LOW,LOW,LOW);
129+
robot.setLeds(COLOR_BLACK);
133130
}

src/Arduino_Robot_Firmware.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Arduino_Robot_Firmware::Arduino_Robot_Firmware(){
88
wire = new TwoWire(I2C_1_SDA, I2C_1_SCL);
99

1010
// I2C external bus
11-
//ext_wire = new TwoWire(I2C_2_SDA,I2C_2_SCL);
11+
ext_wire = new TwoWire(I2C_2_SDA,I2C_2_SCL);
1212

1313
// RGB leds
1414
led1 = new RGBled(LED_1_RED,LED_1_GREEN,LED_1_BLUE);
@@ -63,16 +63,16 @@ int Arduino_Robot_Firmware::begin(){
6363

6464
wire->begin();
6565
wire->setClock(400000);
66-
67-
//ext_wire->begin(ARDUINO_ROBOT_ADDRESS);
66+
67+
connectExternalI2C();
68+
ext_wire->begin(ARDUINO_ROBOT_ADDRESS);
6869

6970
//beginImu();
7071

7172
if (beginAPDS()!=0){
7273
errorLed(ERROR_APDS);
7374
}
74-
75-
75+
7676
beginServo();
7777
//beginI2Cselect();
7878
//connectExternalI2C();
@@ -81,7 +81,6 @@ int Arduino_Robot_Firmware::begin(){
8181
errorLed(ERROR_BMS);
8282
}
8383

84-
8584
if (beginTouch()!=0){
8685
//errorLed(ERROR_TOUCH);
8786
}

src/Arduino_Robot_Firmware.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Arduino_Robot_Firmware{
4545

4646

4747
TwoWire * wire;
48-
//TwoWire * ext_wire;
48+
TwoWire * ext_wire;
4949

5050

5151

0 commit comments

Comments
 (0)