错误:系统'之前的预期初始值设定项

时间:2017-06-08 02:00:19

标签: c++ arduino

所以我试图让我的盾牌机器人避免和漫游物体,这是我的代码。

 system : "Propeller Board of Education"             ' System configuration
  freq   : "PropBOE Square Wave"                      ' Square wave signal generator
  ir     : "PropBOE IR Detect"                        ' IR object detection
  drive  : "PropBOE-Bot Servo Drive"                  ' Propeller Boe-Bot servo control
  time   : "Timing"    


  byte objectL, objectR                               //Variables to store results


  system.Clock(80_000_000)                            //System clock -> 80 MHz
  freq.Out(4, 1000, 3000)                             //P4 sends 1 s, 3 kHz tone to speaker

  repeat                                              //Main loop repeats indefinitely
    objectL := ir.Detect(13, 12)                      //Check for left object
    objectR := ir.Detect(0, 1)                        //Check for right object

    if objectL == 0 and objectR == 0                  //If no objects detected
      drive.Wheels(100, 100)                          // ...go forward
    elseif objectL == 1 and objectR == 1              //If both sensors detect objects
      drive.Wheels(-100, -100)                        //...back up
    elseif objectR == 1                               //If only right detects
      drive.Wheels(-100, 100)                         //...turn left
    elseif objectL == 1                               //If only left detects
      drive.Wheels(100, -100)                         //...turn right

    time.Pause(20)                                    //Wait 20 ms & before repeating loop  

但是,我收到此错误消息。

    Arduino: 1.8.3 (Mac OS X), Board: "Arduino/Genuino Uno"

    Avoid_and_Detect:4: error: expected initializer before 'system'
       system.Clock(80_000_000)                            //System clock -> 80 MHz
   ^
exit status 1
expected initializer before 'system'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您正在尝试使用非C ++的C ++编译器来编译代码。

用C ++重写程序或使用适当的编译器。