SCoop Arduino

上传者: cxsj28 | 上传时间: 2021-05-14 08:42:27 | 文件大小: 655KB | 文件类型: ZIP
Arduino中SCoop多线程库 实例程序代码 /*#include #include */ #include //多线程程序库 #include //超声波传感器 #include //电机传感器 //LiquidCrystal_I2C lcd(0x27,16,2); defineTask(LEDTask);//LED 灯的线程 defineTask(ServoTask);//舵机线程 #define TRIGGER_PIN 2 #define ECHO_PIN 3 #define MAX_DISTANCE 400 NewPing sonar(TRIGGER_PIN,ECHO_PIN,MAX_DISTANCE);//超声波传感器 Servo myservo;//电机传感器 const int replyPin=A2;//光敏传感器 const int soundPin=A0;//声音传感器 const int senorPin=8;//触摸感应键 const int rPin=7;//Led const int ledPin=6; //Led int value=0;//光敏传感器 int sound=0;//声音传感器 int Senor=-1; void LEDTask::setup(){ pinMode(replyPin,INPUT); pinMode(soundPin,INPUT); pinMode(rPin,OUTPUT); } void LEDTask::loop(){ value=analogRead(replyPin);//光敏传感器感应到光强度 Serial.print("光敏传感器感应到光强度:"); Serial.println(value); sound=analogRead(soundPin);//声音感应器感应到声音大小 Serial.print("声音感应器感应到声音大小:"); Serial.println(sound); unsigned int uS=sonar.ping();//超声波传感器感应到数据 Serial.print("超声波传感器感应到数据:"); Serial.println(uS/US_ROUNDTRIP_CM); if(value>400&&(sound>80||uS/US_ROUNDTRIP_CM<5)){ analogWrite(rPin,255); analogWrite(ledPin,0); delay(5000); }else{ analogWrite(rPin,0); analogWrite(ledPin,0); } } void ServoTask::setup(){ pinMode(senorPin,INPUT); myservo.attach(9); myservo.write(0); } void ServoTask::loop(){ Senor=digitalRead(senorPin);//触摸感应键感应 Serial.print("触摸感应键感应:"); Serial.println(Senor); if(Senor==1){ myservo.write(30); delay(100); myservo.write(60); delay(100); myservo.write(90); delay(3000); myservo.write(60); delay(100); myservo.write(30); delay(100); myservo.write(0); } } void setup(){ mySCoop.start(); Serial.begin(9600); } void loop(){ yield(); } //这段程序有一个舵机、一个LED灯(两者都是执行器),两个执行器执行时需要相互不干扰,所以使用多线程

文件下载

资源详情

[{"title":"( 34 个子文件 655KB ) SCoop Arduino","children":[{"title":"SCoop-fix_scoop_compil","children":[{"title":"README.txt <span style='color:#111;'> 228B </span>","children":null,"spread":false},{"title":"TimerUp","children":[{"title":"TimerUp.cpp <span style='color:#111;'> 3.45KB </span>","children":null,"spread":false},{"title":"keywords.txt <span style='color:#111;'> 841B </span>","children":null,"spread":false},{"title":"examples","children":[{"title":"example2","children":[{"title":"example2.ino <span style='color:#111;'> 687B </span>","children":null,"spread":false}],"spread":true},{"title":"example1","children":[{"title":"example1.ino <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"TimerUp.h <span style='color:#111;'> 3.67KB </span>","children":null,"spread":false},{"title":"readme.txt <span style='color:#111;'> 161B </span>","children":null,"spread":false}],"spread":true},{"title":"SCoop","children":[{"title":"SCoop.h <span style='color:#111;'> 33.67KB </span>","children":null,"spread":false},{"title":"keywords.txt <span style='color:#111;'> 718B </span>","children":null,"spread":false},{"title":"SCoop.cpp <span style='color:#111;'> 38.30KB </span>","children":null,"spread":false},{"title":"examples","children":[{"title":"example2","children":[{"title":"example2.ino <span style='color:#111;'> 5.94KB </span>","children":null,"spread":false}],"spread":true},{"title":"example5","children":[{"title":"example5.ino <span style='color:#111;'> 1.85KB </span>","children":null,"spread":false}],"spread":true},{"title":"example3","children":[{"title":"example3.ino <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false}],"spread":true},{"title":"MultipleBlinks","children":[{"title":"MultipleBlinks.ino <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false}],"spread":true},{"title":"example1","children":[{"title":"example1.ino <span style='color:#111;'> 853B </span>","children":null,"spread":false}],"spread":true},{"title":"performance1","children":[{"title":"performance1.ino <span style='color:#111;'> 4.54KB </span>","children":null,"spread":false}],"spread":true},{"title":"MultipleBlinks2","children":[{"title":"MultipleBlinks2.ino <span style='color:#111;'> 2.37KB </span>","children":null,"spread":false}],"spread":false},{"title":"example4","children":[{"title":"example4.ino <span style='color:#111;'> 2.17KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"scoop change log.txt <span style='color:#111;'> 8.18KB </span>","children":null,"spread":false}],"spread":true},{"title":"SCoop user guide V1.2.pdf <span style='color:#111;'> 652.10KB </span>","children":null,"spread":false},{"title":"IOFilter","children":[{"title":"IOFilter.h <span style='color:#111;'> 4.17KB </span>","children":null,"spread":false},{"title":"IOFilter.cpp <span style='color:#111;'> 4.14KB </span>","children":null,"spread":false},{"title":"examples","children":[{"title":"ex1","children":[{"title":"ex1.ino <span style='color:#111;'> 475B </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":".gitignore <span style='color:#111;'> 1.92KB </span>","children":null,"spread":false},{"title":"SchedulerARMAVR","children":[{"title":"SchedulerARMAVR.cpp <span style='color:#111;'> 7.32KB </span>","children":null,"spread":false},{"title":"keywords.txt <span style='color:#111;'> 481B </span>","children":null,"spread":false},{"title":"SchedulerARMAVR.h <span style='color:#111;'> 2.61KB </span>","children":null,"spread":false},{"title":"examples","children":[{"title":"MultipleBlinks","children":[{"title":"MultipleBlinks.ino <span style='color:#111;'> 1.81KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":".gitattributes <span style='color:#111;'> 483B </span>","children":null,"spread":false},{"title":"TimerDown","children":[{"title":"keywords.txt <span style='color:#111;'> 816B </span>","children":null,"spread":false},{"title":"TimerDown.cpp <span style='color:#111;'> 1.62KB </span>","children":null,"spread":false},{"title":"examples","children":[{"title":"example1","children":[{"title":"example1.ino <span style='color:#111;'> 987B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"TimerDown.h <span style='color:#111;'> 2.63KB </span>","children":null,"spread":false},{"title":"readme.txt <span style='color:#111;'> 161B </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明