Skip to content

Commit d82f77a

Browse files
committed
added pid in firmware01
1 parent 5a98853 commit d82f77a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/firmware_01/firmware_01.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ uint8_t leds;
2424
uint8_t sensor_id = 0;
2525

2626

27+
uint8_t pid;
28+
float kp, ki, kd;
29+
30+
2731

2832
void setup(){
2933
Serial.begin(115200);
3034
robot.begin();
35+
robot.setLedBuiltin(HIGH);
3136
line.begin();
3237
tof.begin();
3338

@@ -36,6 +41,9 @@ void setup(){
3641
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
3742
robot.serial->write(packeter.msg,msg_size);
3843

44+
robot.setLedBuiltin(LOW);
45+
46+
3947
code=0;
4048
tmotor=millis();
4149
tsend=millis();
@@ -62,6 +70,16 @@ void loop(){
6270
packeter.unpacketC1B(code,leds);
6371
robot.setAllLeds(leds);
6472
break;
73+
74+
case 'P':
75+
packeter.unpacketC1B3F(code,pid,kp,ki,kd);
76+
if (pid=='L'){
77+
robot.setKPidLeft(kp,ki,kd);
78+
}
79+
if (pid=='R'){
80+
robot.setKPidRight(kp,ki,kd);
81+
}
82+
break;
6583
}
6684
}
6785

0 commit comments

Comments
 (0)