ทำวงจรควบคุมมอเตอร์ระยะไกลด้วยรีโมทวิทยุ+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影片,追蹤數超過2,910的網紅コバにゃんチャンネル,也在其Youtube影片中提到,...
「arduino serial read」的推薦目錄:
- 關於arduino serial read 在 Audom Idea Facebook 的精選貼文
- 關於arduino serial read 在 Audom Idea Facebook 的最佳解答
- 關於arduino serial read 在 コバにゃんチャンネル Youtube 的最佳貼文
- 關於arduino serial read 在 大象中醫 Youtube 的最讚貼文
- 關於arduino serial read 在 大象中醫 Youtube 的最讚貼文
- 關於arduino serial read 在 Simple updated examples of arduino serial communications 的評價
- 關於arduino serial read 在 Arduino Serial.read() only reads the second input - Stack ... 的評價
- 關於arduino serial read 在 Simultaneous Serial reading and writing - Arduino Stack ... 的評價
- 關於arduino serial read 在 Communicate with Arduino through Java 的評價
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 在 コバにゃんチャンネル Youtube 的最佳貼文
arduino serial read 在 大象中醫 Youtube 的最讚貼文
arduino serial read 在 大象中醫 Youtube 的最讚貼文
arduino serial read 在 Arduino Serial.read() only reads the second input - Stack ... 的推薦與評價
... <看更多>
arduino serial read 在 Simultaneous Serial reading and writing - Arduino Stack ... 的推薦與評價
You can indeed simultaneously read and write through the serial port. At the hardware level, the serial port (the UART) is a transmitter and ... ... <看更多>
arduino serial read 在 Simple updated examples of arduino serial communications 的推薦與評價
SERIAL COM - HANDELING MULTIPLE BYTES inside ARDUINO - 01_simple version ... serialRead() reads one byte at a time from the serial buffer. ... <看更多>