วันศุกร์ที่ 28 ธันวาคม พ.ศ. 2561

เครื่องรดน้ำต้นไม้อัตโนมัติ

ผลการค้นหารูปภาพสำหรับ วงจรarduino พร้อมโค้ด

const int analogInPin = A5;
const int relay = 2;
int sensorValue = 0;        // ตัวแปรค่า Analog
int outputValue = 0;        // ตัวแปรสำหรับ Map เพื่อคิด %
void setup() {
  Serial.begin(9600);
  pinMode(relay, OUTPUT);
}
void loop() {
  sensorValue = analogRead(analogInPin);
  Serial.print("Soil Moisture = ");
  Serial.print(outputValue);
  Serial.println(" %");
  if (outputValue <= 40) {  //ตั้งค่า % ที่ต้องการจะรดน้ำต้นไม้
    digitalWrite(relay, HIGH);
  }
  else {
    digitalWrite(relay, LOW);
  }
  delay(1000);
}



วันพุธที่ 19 ธันวาคม พ.ศ. 2561

Arduino วัดอุณหภูมิและความชื้นด้วย DHT11

ผลการค้นหารูปภาพสำหรับ วงจรarduino พร้อมโค้ด

DHT11 มีทั้งหมดอยู่ 4 ขา คือ
ลำดับ
ขาใช้งาน
1
VCC
DATA
NC
GND
DHT11 จะใช้วิธีการส่งข้อมูลให้กับไมโครคอนโทรลเลอร์ด้วยสายเพียงเส้นเดียวในแบบของดิจิตอลลอจิก
/* IOXhop - www.ioxhop.com */
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
   Serial.begin(9600); 
   Serial.println("DHTxx test!");
   dht.begin();
}
void loop() {
   float h = dht.readHumidity();
   float t = dht.readTemperature();
   float f = dht.readTemperature(true);
   if (isnan(h) || isnan(t) || isnan(f)) {
     Serial.println("Failed to read from DHT sensor!");
   return;
   }

   float hi = dht.computeHeatIndex(f, h);

   Serial.print("Humidity: "); 
   Serial.print(h);
   Serial.print(" %\t");
   Serial.print("Temperature: "); 
   Serial.print(t);
   Serial.print(" *C ");
   Serial.print(f);
   Serial.print(" *F\t");
   Serial.print("Heat index: ");
   Serial.print(hi);
   Serial.println(" *F");  
   delay(2000);
}

วันจันทร์ที่ 10 ธันวาคม พ.ศ. 2561

7 segment สวิตสั่งนับเลขกลับ



void setup()
{
pinMode(11, OUTPUT);   
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);   
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);   
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, INPUT);
pinMode(1, INPUT);

}



void loop(){
  gHu ();
}
void gHu (){
  int XD = digitalRead (4);
  if (XD==0){
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, LOW);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6,HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);     
    }
 int DX = digitalRead (1);
  if (DX==0){

    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6,HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
  }
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
}
 
วิธีทำ
เรากำหนดขาต่อ 7 Segment ว่า
pinMode(11, OUTPUT);   
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);   
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);   
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
จะขาไหนก็ได้
แล้วสวิตช์
pinMode(4, INPUT);
pinMode(1, INPUT);
ใน void set up
จากนั้นเขียน code สวิตช์ ขา 4แล้วเอาขาที่กำหนดมาใส่ตั้งแต่ 0-9
int XD = digitalRead (4);
 if (XD==0){
เอาขาที่กำหนดไว้ตั้งให้เป็นตัวเลข
เลข 0
   digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, LOW);
    delay(1000);
เลข 1
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
เลข 2
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 3
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 4
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 5
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 6
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6,HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 7
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
เลข 8
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 9
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);     
จากนั้นเขียน code สวิตช์ ขา 4แล้วเอาขาที่กำหนดมาใส่ตั้งแต่ 8-1
 int DX = digitalRead (1);
  if (DX==0){
ใสตัวเลข 8-1
 
เลข 8
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 7
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
เลข 6
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6,HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 5
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 4
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 3
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 2
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(1000);
เลข 1
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    delay(1000);
จากนั้นเราก็ใส่
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
เพื่อกันให้หยุดทำงานถ้าส​วิ​ดไม่ถูกกด
แล้วเราก็สร้างฟังก์ชั่นใหม่เพื่อจะได้ไม่งงการเขียน code
gHu ();
แล้วเอาที่เขียนทั้งหมดใส่ใน void loop
จากนั้น เอา ภาษา C ไปใส่ Arduino พอกดสวิตช์ขา 1 7 Segment จะเป็นเลข 8-1 
กดสวิตช์ขา 4 7 Segment จะเป็นเลข 0-9
·         รับลิงก์



ึ7 segment มอเตอร์ 2 ตัว



# include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2) ;

void setup() {
lcd.begin(16,2);
pinMode (10,INPUT);
pinMode (9,INPUT);
pinMode (8,OUTPUT);
pinMode (7,OUTPUT);
}

void loop() {
 int sd = digitalRead(10);
 int hd = digitalRead(9);
 if (sd == 0) {
lcd.setCursor(0,1);
lcd.print("Motor 1");
digitalWrite(8, HIGH);
delay (500);
lcd.setCursor(0,1);
lcd.print("       ");
digitalWrite(8, LOW);
delay (500);
}
 if (hd == 0) {
lcd.setCursor(0,1);
lcd.print("Motor 2");
digitalWrite(7, HIGH);
delay (500);
lcd.setCursor(0,1);
lcd.print("       ");
digitalWrite(7, LOW);
delay (500);
 }
 digitalWrite(8, LOW);
 digitalWrite(7, LOW);
 }
วิธีทำ
เขียน# include <LiquidCrystal.h>กับLiquidCrystal lcd(12,11,5,4,3,2) ;ไว้คนละบรรทัดบนสุด
จากนั้นเขียน 
lcd.begin(16,2);
pinMode (10,INPUT);
pinMode (9,INPUT);
pinMode (8,OUTPUT);
pinMode (7,OUTPUT);
ใน void set up โดย
lcd.begin(16,2);
คือ อักษรไม่เกิน 16 ตัว มีอยู่ 2 บรรทัด
pinMode (8,OUTPUT);  pinMode (7,OUTPUT);
คือ ขาที่ต่อมอเตอร์
pinMode (10,INPUT);  pinMode (9,INPUT);
คือ สวิตช์
ใน void loop เขียนฟังก์ชั่นสวิตช์ใส่คำพูดกับบรรทัด แล้วหน่วงเวลา 0.5 วิ
int sd = digitalRead(10);
 int hd = digitalRead(9);
if (sd == 0) {
lcd.setCursor(0,1);
lcd.print("Motor 1");
digitalWrite(8, HIGH);
delay (500);
lcd.setCursor(0,1);
lcd.print("       ");
digitalWrite(8, LOW);
delay (500);
}
 if (hd == 0) {
lcd.setCursor(0,1);
lcd.print("Motor 2");
digitalWrite(7, HIGH);
delay (500);
lcd.setCursor(0,1);
lcd.print("       ");
digitalWrite(7, LOW);
delay (500);
 }
 digitalWrite(8, LOW);
 digitalWrite(7, LOW);
 }


digitalWrite(8, LOW);
digitalWrite(7, LOW);
เพื่อกันให้หยุดทำงานถ้าส​วิ​ดไม่ถูกกด
จากนั้นเอา ภาษา C ไปใส่  Arduino
พอกดสวิตช์ขา10แล้ว มอเตอร์กับ LCD จะทำงานพร้อมกัน โดย มอเตอร์จะหมุนกับดับ ส่วน LCD จะมีคำว่า Motor 1 แล้วก็หายไป เพราะ หน่วงเวลา 0.5 วิ

ส่วนกดสวิตช์ขา9แล้ว มอเตอร์กับ LCD จะทำงานพร้อมกัน โดย มอเตอร์จะหมุนกับดับ ส่วน LCD จะมีคำว่า Motor 2 แล้วก็หายไป เพราะ หน่วงเวลา 0.5 วิ

7 segment





void setup() {
pinMode (11,OUTPUT);
pinMode (10,OUTPUT);
pinMode (9,OUTPUT);
pinMode (8,OUTPUT);
pinMode (7,OUTPUT);
pinMode (6,OUTPUT);
pinMode (5,OUTPUT);
}
void loop() {
   mul();
  kill();
}
void mul () {
  digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, HIGH);
delay (1000);
digitalWrite(11,  HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
}
void kill (){
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11,  HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
}
วิธีทำ
เรากำหนดขา 11,10,9,8,7,6,5 เป็น OUTPUTpinMode (11,OUTPUT);
pinMode (10,OUTPUT);
pinMode (9,OUTPUT);
pinMode (8,OUTPUT);
pinMode (7,OUTPUT);
pinMode (6,OUTPUT);
pinMode (5,OUTPUT);
ใน void set up
จากนั้น จะทำเป็นเลข 1 เขียน code ดังนี้
digitalWrite(11,  HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
เลข 2
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
เลข 3
digitalWrite(11, LOW);
digitalWrite(10, LOW); 
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, LOW);
delay (1000);
เลข 4
digitalWrite(11, HIGH);
digitalWrite(10, LOW); 
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
เลข 5
digitalWrite(11, LOW);
digitalWrite(10, HIGH); 
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
เลข 6
digitalWrite(11, HIGH);
digitalWrite(10, HIGH); 
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
เลฃ 7
digitalWrite(11, LOW);
digitalWrite(10, LOW); 
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
เลข 8

digitalWrite(11, LOW);
digitalWrite(10, LOW); 
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
เลข 9
digitalWrite(11, LOW);
digitalWrite(10, LOW); 
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,LOW);
digitalWrite(5, LOW);
delay (1000);
digitalWrite(11,  HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6,HIGH);
digitalWrite(5, HIGH);
delay (1000);
ตั้งฟังก์ชั่น  mul();   kill(); เพื่อจะได้ไม่สับสนต่อการเขียนจะแบบไหนก็ได้ เอาขาที่กำหนดไปใส่   mul(); (0-9) kill(); (8-1) เขียนต่อ 
จากนั้น เอา ภาษา C ไปใส่ Arduino แล้ว 7 Segment จะเป็นเลข0-9 และ 8-1


มินิโปรเจค Arduino Calculator (แก้ไข)

 https://www.electronicshub.org/arduino-calculator/ #include <LiquidCrystal.h> ...