用户
 找回密码
 立即注册

QQ登录

只需一步,快速开始

点击进入授权页面

只需一步,快速开始

  • QQ空间
  • 回复
  • 收藏

[已解决] 程序错误,求助

该用户从未签到

asdwe696 新手上路 2018-2-13 12:30 楼主
本帖最后由 asdwe696 于 2018-2-13 17:32 编辑

下面的一半是processing的程序。我之前对此不了解


这是arduino权威指南第89页的程序,串口通讯有关于arduino和Processing的。可我敲上去显示有错误,应给是我哪里敲错了?可是我看了好几遍没找到是哪错了啊.是因为有两个setup的原因吗?这实际上应该是两个程序?
void setuo()
{
  Serial.begin(9600);
}
void loop()
{
  int value1=10;
  int value2=100;
  int value3=1000;
  Serial.print('H');
  Serial.print(",");
  Serial.print(value1,DEC);
  Serial.print(",");
  Serial.print(value2,DEC);
  Serial.print(",");
  Serial.print(value3,DEC);
  Serial.print(",");
  Serial.println();
  delay(100);
}
import processing.serial.*;
Serial myport;
char HEADER='H';
short LF=10;
short portIndex=1;
void setup(){
  size(200,200);
  println(Serial.list());
  println("Connecting to->"+Serial.list()[protIndeex]);
  myport=new Serial(this,Serial.list()[portIndex],9600);
}
void draw(){
}
void serialEvent(Serial p)
{
  String message=myport.readStringUntil(LF);
  if(message!=null)
  {
    print(message);
    string[]date=message.split(",");
    if(dataa[0].charAt(0)==HEADER&&data.length>3)
    {
      for(int i=1;i<data.length-1;i++)
      {
        println("Value"+i+"="+data);
      }
      println();
    }
  }
}



错误信息是这样的
Arduino:1.7.2 (Windows 8.1), 板:"Arduino Uno"

构建选项已变更,全部重新构建



D:\搜狗高速下载\arduino-1.7.2\arduino-1.7.2/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10702 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -ID:\搜狗高速下载\arduino-1.7.2\arduino-1.7.2\hardware\arduino\avr\cores\arduino -ID:\搜狗高速下载\arduino-1.7.2\arduino-1.7.2\hardware\arduino\avr\variants\standard C:\Users\hongyi\AppData\Local\Temp\build6662697751941724120.tmp\sketch_feb12a.cpp -o C:\Users\hongyi\AppData\Local\Temp\build6662697751941724120.tmp\sketch_feb12a.cpp.o

sketch_feb12a.ino:6:18: error: variable or field 'serialEvent' declared void

sketch_feb12a.ino:6:25: error: expected ')' before 'p'

sketch_feb12a.ino:21:1: error: 'import' does not name a type

sketch_feb12a.ino:22:1: error: 'Serial' does not name a type

sketch_feb12a.ino: In function 'void setup()':

sketch_feb12a.ino:27:15: error: 'size' was not declared in this scope

sketch_feb12a.ino:28:18: error: 'class HardwareSerial' has no member named 'list'

sketch_feb12a.ino:28:24: error: 'println' was not declared in this scope

sketch_feb12a.ino:29:36: error: 'class HardwareSerial' has no member named 'list'

sketch_feb12a.ino:29:43: error: 'protIndeex' was not declared in this scope

sketch_feb12a.ino:30:3: error: 'myport' was not declared in this scope

sketch_feb12a.ino:30:14: error: expected type-specifier before 'Serial'

sketch_feb12a.ino:30:14: error: expected ';' before 'Serial'

sketch_feb12a.ino: At global scope:

sketch_feb12a.ino:34:18: error: variable or field 'serialEvent' declared void

sketch_feb12a.ino:34:25: error: expected ')' before 'p'

编译有误。



发新帖
发表评论
高级模式  
您需要登录后才可以回帖 登录 | 立即注册  
关闭

推荐主题 上一条 /2 下一条