|
我用藍芽輸入訊號 是否有辦法可以在arduino 裡面看是什麼數值嗎
可否可以同時 輸出然後又輸入到同一塊板子
#include <MeetAndroid.h>
MeetAndroid meetAndroid;
int redLed = 9;
int greenLed = 10;
int blueLed = 11;
int sensorPin1 = 2;
int sensorPin2 = 3;
int sensorPin3 = 4;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
void setup()
{
Serial.begin(57600);
meetAndroid.registerFunction(red, 'r');
meetAndroid.registerFunction(green, 'g');
meetAndroid.registerFunction(blue, 'b');
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, HIGH);
digitalWrite(blueLed, HIGH);
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(sensorPin2, INPUT);
}
void loop()
{
meetAndroid.receive();
sensorValue1 = analogRead(sensorPin1);
sensorValue2 = analogRead(sensorPin2);
sensorValue3 = analogRead(sensorPin3);
Serial.print(sensorValue1);
Serial.print(sensorValue2);
Serial.print(sensorValue3);
}
void red(byte flag, byte numOfValues)
{
sensorValue1 = analogWrite(redLed, meetAndroid.getInt());
}
void green(byte flag, byte numOfValues)
{
sensorValue2 = analogWrite(greenLed, meetAndroid.getInt());
}
void blue(byte flag, byte numOfValues)
{
sensorValue3 = analogWrite(blueLed, meetAndroid.getInt());
}
sensorValue 是我想印出藍芽接收到的數值
可是Serial Monitor 不知道要調成什麼才能看
然後想要跑到 analog 2. 3 .4 做輸入
不知道是否可行 |
|