c_cpp 该软件是名为“Arduino Uno Port Control”的项目的Arduino Uno固件。该项目的目的是控制数字化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 该软件是名为“Arduino Uno Port Control”的项目的Arduino Uno固件。该项目的目的是控制数字化相关的知识,希望对你有一定的参考价值。
byte lineEnding = 0x0A;
//Data array that the received info from android app is recorded. Every byte corresponds to a digital pin.
byte readBuffer[15]; //For example readBuffer[5] is for digital pin 5.
byte defaultByte = 0x10; //On start all arduino digital pins must be input for electrical protection.
//Pins 0 and 1 are used for serial comminations. So read
void setup() {
for (int i=0; i < sizeof(readBuffer)-1 ; ++i) {
readBuffer[i] = defaultByte;}
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 14) {
Serial.readBytesUntil(lineEnding, (char*) readBuffer, 15);
for (int i=2; i < sizeof(readBuffer)-1 ; i++ ) {
if( bitRead(readBuffer[i], 4 )) { pinMode(i,INPUT);} else { pinMode(i,OUTPUT);}
}
for (int i=2; i < sizeof(readBuffer)-1 ; i++ ) {
if( bitRead(readBuffer[i], 0 )) { digitalWrite(i,HIGH);} else { digitalWrite(i,LOW);}
}
}
}
以上是关于c_cpp 该软件是名为“Arduino Uno Port Control”的项目的Arduino Uno固件。该项目的目的是控制数字化的主要内容,如果未能解决你的问题,请参考以下文章