雖然這篇serial.print arduino鄉民發文沒有被收入到精華區:在serial.print arduino這個話題中,我們另外找到其它相關的精選爆讚文章
在 serial.print產品中有3篇Facebook貼文,粉絲數超過13萬的網紅Audom Idea,也在其Facebook貼文中提到, ทำวงจรควบคุมมอเตอร์ระยะไกลด้วยรีโมทวิทยุ+Arduino https://www.youtube.com/watch?v=PsXB_kWwp8Y -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\...
serial.print 在 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 在 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 在 Audom Idea Facebook 的精選貼文
ตู้ไปรษณีย์แจ้งเตือนทาง Line สอนทำแบบระเอียดยิ๊บ..
---------------------
จากเมื่อสัปดาห์ที่แล้วผมได้โพสต์วีดีโอทดสอบการทำงานของตู้ไปรษณีย์แจ้งเตือนทางไลน์ไป ก็มีหลายๆคนสนใจผมจึงได้ทำคลิปขึ้นมา เพื่อพาทุกคนทำ ผมวังว่าคลิปนี้จะมีประโยชน์สำหรับใครหลายคนนะครับผม😊
-------------------------------------------------
คลิป https://www.youtube.com/watch?v=_cVsQ1oRuRA&t=108s
--------------------------------------------------
โค้ด
void Line_Notify1(String message1) ;
#include <ESP8266WiFi.h>
#include <DHT.h>
#define WIFI_SSID "ชื่อ wifi" /////////////*************แก้
#define WIFI_PASSWORD "รหัส wifi"////////**************แก้
#define LINE_TOKEN_PIR "line token"////***************แก้
#define PirPin D6
#define DHTPIN D7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
String message1 = "ข้อความแจ้งเตือน";//****************แก้
bool beep_state = false;
bool send_state = false;
uint32_t ts, ts1, ts2;
void setup() {
Serial.begin(115200);
Serial.println();
pinMode(PirPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
dht.begin();
Serial.println("connecting");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
delay(10000);
Serial.println("Pir Ready!!");
read_sensor();
ts = ts1 = ts2 = millis();
}
void loop() {
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
if ((ts - ts2 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts1 >= 5000) && (beep_state == true)) {
beep_state = false;
}
if ((digitalRead(PirPin) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin) == HIGH) delay(100);
Serial.println("Detect !");
Line_Notify1(message1);
beep_state = true;
}
delay(10);
}
void Line_Notify1(String message) {
WiFiClientSecure client;
if (!client.connect("notify-api.line.me", 443)) {
Serial.println("connection failed");
delay(2000);
return;
}
String req = "";
req += "POST /api/notify HTTP/1.1\r\n";
req += "Host: notify-api.line.me\r\n";
req += "Authorization: Bearer " + String(LINE_TOKEN_PIR) + "\r\n";
req += "Cache-Control: no-cache\r\n";
req += "User-Agent: ESP8266\r\n";
req += "Content-Type: application/x-www-form-urlencoded\r\n";
req += "Content-Length: " + String(String("message=" + message1).length()) + "\r\n";
req += "\r\n";
req += "message=" + message1;
// Serial.println(req);
client.print(req);
delay(20);
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
break;
}
}
}
void read_sensor() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
}
----------------------------------------------------------