ทำวงจรควบคุมมอเตอร์ระยะไกลด้วยรีโมทวิทยุ+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影片中提到,...
「serial print arduino」的推薦目錄:
serial print arduino 在 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);
}
}
serial print arduino 在 Bryan Wee Youtube 的評價
serial print arduino 在 Travel Thirsty Youtube 的評價
serial print arduino 在 スキマスイッチ - 「全力少年」Music Video : SUKIMASWITCH / ZENRYOKU SHOUNEN Music Video Youtube 的評價
serial print arduino 在 CSJH-Maker - 1.利用序列埠視窗顯示 的相關結果
等,但9600已經非常夠快了. 例如:. void setup(){. Serial.begin(9600);. } 但是若要顯示,必須要使用Serial.print(); 函數(下表中x=1 , y=3.1415926 ) ... ... <看更多>
serial print arduino 在 Arduino 筆記– Serial Library 介紹 - Cooper Maa 的相關結果
所有Arduino 的板子至少都有一個Serial port (又稱UART ... 編譯這支程式(print.pde)並上傳到Arduino 後,打開Serial Monitor,然後你就會看到底下 ... ... <看更多>
serial print arduino 在 Serial.print() - Arduino Reference 的相關結果
Serial.print() · Description. Prints data to the serial port as human-readable ASCII text. This command can take many forms. · Syntax. Serial.print(val) ... <看更多>