ทำวงจรควบคุมมอเตอร์ระยะไกลด้วยรีโมทวิทยุ+Arduino
https://www.youtube.com/watch?v=PsXB_kWwp8Y
-------------------------------------------
โค้ด
int ch1;
int ch2;
int ch3;
const int relay1 = 2;
const int relay2 = 3;
const int relay3 = 4;
const int relay4 = 5;
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(A1);
pinMode(6, INPUT); // Set our input pins as such
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
Serial.begin(9600); // Pour a bowl of Serial
}
void loop() {
ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of
ch2 = pulseIn(6, HIGH, 25000); // each channel
ch3 = pulseIn(7, HIGH, 25000);
Serial.print("Channel 1:"); // Print the value of
Serial.println(ch1); // each channel
Serial.print("Channel 2:");
Serial.println(ch2);
Serial.print("Channel 3:");
Serial.println(ch3);
delay(10); // I put this here just to make the terminal
// window happier
if (ch3 >1700)
{
digitalWrite(relay1,LOW);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, LOW);
digitalWrite(relay4, HIGH);
}
else {
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}
if (ch3 <1200)
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, LOW);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, LOW);
}
if (ch2 >1700)
{
digitalWrite(relay1,LOW);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, LOW);
}
if (ch2 <1300)
{
digitalWrite(relay1,HIGH);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, HIGH);
}
}
同時也有10000部Youtube影片,追蹤數超過62萬的網紅Bryan Wee,也在其Youtube影片中提到,...
「arduino serial read」的推薦目錄:
arduino serial read 在 Audom Idea Facebook 八卦
ทำวงจรควบคุมมอเตอร์ระยะไกลด้วยรีโมทวิทยุ+Arduino
https://www.youtube.com/watch?v=PsXB_kWwp8Y
-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
โค้ด
int ch1;
int ch2;
int ch3;
const int relay1 = 2;
const int relay2 = 3;
const int relay3 = 4;
const int relay4 = 5;
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(A1);
pinMode(6, INPUT); // Set our input pins as such
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
Serial.begin(9600); // Pour a bowl of Serial
}
void loop() {
ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of
ch2 = pulseIn(6, HIGH, 25000); // each channel
ch3 = pulseIn(7, HIGH, 25000);
Serial.print("Channel 1:"); // Print the value of
Serial.println(ch1); // each channel
Serial.print("Channel 2:");
Serial.println(ch2);
Serial.print("Channel 3:");
Serial.println(ch3);
delay(10); // I put this here just to make the terminal
// window happier
if (ch3 >1700)
{
digitalWrite(relay1,LOW);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, LOW);
digitalWrite(relay4, HIGH);
}
else {
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}
if (ch3 <1200)
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, LOW);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, LOW);
}
if (ch2 >1700)
{
digitalWrite(relay1,LOW);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, LOW);
}
if (ch2 <1300)
{
digitalWrite(relay1,HIGH);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, HIGH);
}
}
arduino serial read 在 Bryan Wee Youtube 的評價
arduino serial read 在 Travel Thirsty Youtube 的評價
arduino serial read 在 スキマスイッチ - 「全力少年」Music Video : SUKIMASWITCH / ZENRYOKU SHOUNEN Music Video Youtube 的評價
arduino serial read 在 CSJH-Maker - 2.認識Serial.read() - Google Sites 的相關結果
活動一Serial.print(). 1.先將此程式碼(紫色的字)上傳至Arduino中. void setup(){. Serial.begin(9600);. } void loop(){. if(Serial.available()){. ... <看更多>
arduino serial read 在 Arduino序列埠通訊程式Serial.read()讀取到ÿ 字元的補充說明 的相關結果
Arduino 序列埠通訊程式Serial.read()讀取到ÿ 字元的補充說明 ... 將此上傳程式到Arduino,再開啟「序列埠監控視窗」,並輸入”123″字串,將能看到Arduino接收到完整的 ... ... <看更多>
arduino serial read 在 Serial.read() - Arduino Reference 的相關結果
read (). Description. Reads incoming serial data. Serial.read() inherits from the Stream utility class. ... <看更多>