05/01/2569

์New ! ภาคเรียนที่ 2 ครูเต้ง เทคโนฯ NeoPixel Ring 12

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้  คำสั่งเขียน  Neo Pixel  - 12 พิมพ์ค้นหาอุปกรณ์ ชื่อว่า NeoPixel Ring 12


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  strip.begin();
  strip.show(); 
}
void loop() {
  colorWipe(strip.Color(255, 0, 0), 50); // Vermelho
  colorWipe(strip.Color(0, 255, 0), 50); // Verde
  colorWipe(strip.Color(0, 0, 255), 50); // Azula
  theaterChase(strip.Color(127, 127, 127), 50); // branco
  theaterChase(strip.Color(127, 0, 0), 50); // Vermelho
  theaterChase(strip.Color(0, 0, 127), 50); // Azul
  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}
void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //faz 10 ciclos
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c); //liga a cada 3 pixeis
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);//desativa a cada 3 pixeis
      }
    }
  }
}
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) { // alterna as 256 cores na roda
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //liga a cada 3 pixeis
      }
      strip.show();
      delay(wait);
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0); //desativa a cada 3 pixeis
      }
    }
  }
}
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 130;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}



์New ! ภาคเรียนที่ 2 ครูเต้ง เทคโนฯ ปุ่มกดเสียง และสัญญาณเสียง ตัวต้านทาน 560 หน่วยเป็น โอห์ม (Ω)

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้  คำสั่งเขียน 

 ปุ่มกดเสียง และสัญญาณเสียง ตัวต้านทาน 560 โอห์ม (Ω) 


int cNote = 9;

int dNote = 8;

int eNote = 7;

int fNote = 6;

int gNote = 5;

int aNote = 4;

int bNote = 3;

int Piezo = 2;

double c = 261.63;// the frequency of note c

double d = 293.66;// the frequency of note d

double e = 329.63;// the frequency of note e

double f = 349.23;// the frequency of note f

double g = 392;// the frequency of note g

double a = 440;// the frequency of note a

double b = 493.88;// the frequency of note b

void setup()

{

  pinMode(cNote, INPUT);

  pinMode(dNote, INPUT);

  pinMode(eNote, INPUT);

  pinMode(fNote, INPUT);

  pinMode(gNote, INPUT);

  pinMode(aNote, INPUT);

  pinMode(bNote, INPUT);

  pinMode(Piezo, OUTPUT);

  Serial.begin(9600);

}

void loop()

{

  Serial.println(digitalRead(cNote));

  Serial.println(digitalRead(dNote));

  Serial.println(digitalRead(eNote));

  Serial.println(digitalRead(fNote));

  Serial.println(digitalRead(gNote));

   Serial.println(digitalRead(aNote));

   Serial.println(digitalRead(bNote));

  if (digitalRead(cNote) == 1) {

    tone(Piezo, c, 250); // plays note c

  }else if (digitalRead(dNote) == 1) {

    tone(Piezo, d, 250); // plays note d

  }else if (digitalRead(eNote) == 1) {

    tone(Piezo, e, 250); // plays note e 

  }else if (digitalRead(fNote) == 1) {

    tone(Piezo, f, 250); // plays note f 

  }else if (digitalRead(gNote) == 1) {

    tone(Piezo, g, 250); // plays note g 

  }else if (digitalRead(aNote) == 1) {

    tone(Piezo, a, 250); // plays note a 

  }else if (digitalRead(bNote) == 1) {

    tone(Piezo, b, 250); // plays note b

  } else {

    noTone(Piezo);

  }

  delay(10);

}



28/04/2568

Arduino C++ (ไฟวิ่ง) ครูเต้ง เทคโนฯ


📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้คำสั่งเขียน 

int led1 = 2; // กำหนดขาใช้งาน 

int led2 = 3; 

int led3 = 4; 

int led4 = 5; 

void setup() 

pinMode(led1, OUTPUT); // กำหนดขาทำหน้าที่ OUTPUT 

pinMode(led2, OUTPUT); 

pinMode(led3, OUTPUT); 

pinMode(led4, OUTPUT); 

void loop() 

digitalWrite(led1,HIGH); // ไฟ LED 1 ติด 500 ms 

delay(500); 

digitalWrite(led1,LOW); // ไฟ LED 1 ดับ500 ms 

delay(500); 

digitalWrite(led2,HIGH); 

delay(500); 

digitalWrite(led2,LOW); 

delay(500); 

digitalWrite(led3,HIGH); 

delay(500); 

digitalWrite(led3,LOW); 

delay(500); 

digitalWrite(led4,HIGH); 

delay(500); 

digitalWrite(led4,LOW); 

delay(500); 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้วงจร






12/04/2568

Theme 6 วงจรพัฒนาประยุกต์การทำงานของระบบ Capteur Gaz

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้   คำสั่งเขียน 

#include<LiquidCrystal.h>
LiquidCrystal lcd(13, 7, 6, 5, 4, 3);
int capteurGaz = A0;
int capteurTemp = A1;
int buzzer = 2;
int photoresistance = A2;
int del = 8;
int del_manuel = 9;
int btn_gaz_pin = 10;
int btn_lumi_pin = 11;
int manuel_pin = 12;
int molette = A3;
int manuel;
int btn_gaz;
int btn_lumi;
int btn_manuel;
void setup() {
  pinMode(13, OUTPUT);
  for (int i = 3; i < 7; i++){ // l'écran LCD
  pinMode(i, OUTPUT);
  }
  for (int y = 10; y < 12; y++){ // les boutons
    pinMode(y, INPUT);
  }
  pinMode(8, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  // PARTIE CAPTEUR GAZ
  int seuilGaz = 150;
  float gaz = analogRead(capteurGaz); // récupère le taux de gaz
  if(gaz >= seuilGaz){tone(buzzer, 900, 750);}
  // PARTIE CAPTEUR TEMPÉRATURE
  float temp = analogRead(capteurTemp);
  float volt = (temp/1024.0)*5.0;
  float temperature= (volt-0.5)*100;
  // vérifie la température et allume le buzzer si elle dépasse un seuil
  if(temperature >31)
  {tone(buzzer, 500, 500);}
  else if(temperature >30)
    {tone(buzzer, 400, 500);}
  else if(temperature >29.5)
  {tone(buzzer, 300, 500);}
  else if(temperature >29)
  {tone(buzzer, 250, 500);}
  else if(temperature >28.5)
    {tone(buzzer, 200, 500);}
  else if(temperature >28)
    {tone(buzzer, 150, 500);}
  
  if (temperature < -11)
  {tone(buzzer, 500, 500);}
  else if(temperature <-10)
    {tone(buzzer, 400, 500);}
  else if(temperature <-9.5)
  {tone(buzzer, 300, 500);}
  else if(temperature <-9)
  {tone(buzzer, 250, 500);}
  else if(temperature <-8.5)
    {tone(buzzer, 200, 500);}
  else if(temperature <-8)
    {tone(buzzer, 150, 500);}
  // PARTIE PHOTORESISTANCE
  int luminosite = analogRead(photoresistance); //capture la luminosité
  int val = map(luminosite, 100, 997, 0, 255);
  if(manuel==1){val = map(analogRead(molette), 0, 1023, 0, 255);}
  analogWrite(del, val); // allume les leds
  int luminosite_del = map(val, 0, 255, 0, 100); //TODO
  // PARTIE ECRAN LCD
  btn_gaz = digitalRead(btn_gaz_pin);
  btn_lumi = digitalRead(btn_lumi_pin);
  manuel = digitalRead(manuel_pin);
  lcd.clear();
  lcd.setCursor(0,0); //reset l'écran
  if(manuel==1){
    lcd.print("manuel: = "); lcd.print(luminosite_del); //affiche la luminosité.
    delay(500);
  }
  else if(btn_gaz == LOW){
    lcd.print("GAZ = "); lcd.print(gaz); //affiche la quantité de gaz.
    delay(500);
  }
  else if(btn_lumi == LOW){
    lcd.print("lumi% = "); lcd.print(luminosite_del); //affiche la luminosité.
    delay(500);
  }
  else {
    lcd.print("temp = "); lcd.print(temperature); //affiche la quantité de gaz.
    lcd.print("°C");
    delay(500);
  }
  //MONITEUR SÉRIE
  Serial.println(manuel);
  Serial.print("temperature: ");
  Serial.println(temperature);
  Serial.print("gaz: ");
  Serial.println(gaz);
  Serial.print("luminosite DEL: ");
  Serial.print(luminosite_del);Serial.println("%");
  Serial.println(""); //saut de ligne
}


📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ วงจร




Theme 6 วงจรพัฒนาเซ็นเซอร์ตรวจจับแก๊สพร้อมไฟ LED 3 ดวงและสัญญาณเตือน

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้  คำสั่งเขียน 


int const PIN_SGAS = A1;
int LED_green = 6;
int LED_yellow = 5;
int LED_red = 4;
int buzzer = 3;
void setup(){
    pinMode(LED_green, OUTPUT);
    pinMode(LED_yellow, OUTPUT);
    pinMode(LED_red, OUTPUT);
pinMode(buzzer, OUTPUT);
    Serial.begin(9600);
}
void loop(){
    int value = analogRead(PIN_SGAS);
    value = map(value, 300, 750, 0, 100);
  if(value < 30){
    digitalWrite(LED_green, HIGH);
    digitalWrite(LED_yellow, LOW );
    digitalWrite(LED_red, LOW );
    digitalWrite(buzzer, LOW ); 
  }
  else if(value >= 30 & value < 50){
    digitalWrite(LED_yellow, HIGH );
    digitalWrite(LED_red, LOW );
    digitalWrite(LED_green, LOW );
    digitalWrite(buzzer, LOW ); 
  }
   else {
   digitalWrite(LED_red, HIGH );
     digitalWrite(LED_yellow, LOW );
     digitalWrite(LED_green, LOW );
    tone(buzzer, 500); // Send 1KHz sound signal...
  delay(300);   // ...for 1 sec
  noTone(buzzer);     // Stop sound...
  delay(50);  // ...for 1sec
  }
  delay(250);
}

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ วงจร 






Theme 6 วงจรจำลองการทำงานของระบบ BELAJAR LCD 16X2

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้  คำสั่งเขียน 

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int adc;
void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(A0, INPUT);
}
void loop()
{
  adc = analogRead(A0);
  lcd.setCursor(0, 0);
  lcd.print("NILAI ADC = ");
  lcd.setCursor(12, 0);
  lcd.print(adc);
  Serial.println(adc);
  delay(1000);
  lcd.setCursor(12, 0);
  lcd.print("    ");
  if (adc<=102){
  lcd.setCursor(0,1);
  lcd.print("[          ]= 0%");
  }
  if (adc>=103 && adc<=204){
  lcd.setCursor(0,1);
  lcd.print("[=         ]=10%");
  }
  if (adc>=205 && adc<=306){
  lcd.setCursor(0,1);
  lcd.print("[==        ]=20%");
  }
  if (adc>=307 && adc<=408){
  lcd.setCursor(0,1);
  lcd.print("[===       ]=30%");
  }
  
  if (adc>=309 && adc<=510){
  lcd.setCursor(0,1);
  lcd.print("[====      ]=40%");
  }
  if (adc>=511 && adc<=612){
  lcd.setCursor(0,1);
  lcd.print("[=====     ]=50%");
  }
  if (adc>=613 && adc<=714){
  lcd.setCursor(0,1);
  lcd.print("[======    ]=60%");
  }
  
  if (adc>=715 && adc<=816){
  lcd.setCursor(0,1);
  lcd.print("[=======   ]=70%");
  }
  if (adc>=817 && adc<=918){
  lcd.setCursor(0,1);
  lcd.print("[=======   ]=80%");
  } 
  if (adc>=919 && adc<=1020){
  lcd.setCursor(0,1);
  lcd.print("[========= ]=90%");
  }
  if (adc>=1021 && adc<=1023){
  lcd.setCursor(0,1);
  lcd.print("[==========]100%");
  }

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ วงจร 




Theme 6 โครงงานประยุกต์ New Gas Sensor with piezo and led and lcd Display

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ คำสั่งเขียน 

#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int buzzer = 10;
void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  pinMode(13,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(6,OUTPUT);
}
void loop() {
  int gas_data;
  gas_data = analogRead(A0);
  lcd.setCursor(00,00);
  lcd.print("Gas :");
  lcd.setCursor(6,00);
  lcd.print(gas_data);
  if(gas_data > 800){
  digitalWrite(13,HIGH);
    delay(100);
    digitalWrite(13,LOW);
    lcd.setCursor(00,1);
    lcd.print("DANGER");
    tone(buzzer, 1000, 200);
  }else if(gas_data > 700){
    digitalWrite(6,HIGH);
  delay(100);
    digitalWrite(6,LOW);
    lcd.setCursor(00,1);
    lcd.print("WARNING");
    tone(buzzer, 250, 50);
  }else {
    digitalWrite(7,HIGH);
    delay(100);
    digitalWrite(7,LOW);
    lcd.setCursor(00,1);
    lcd.print("SAFE");
    noTone(buzzer);
  }
  Serial.println(gas_data);
  delay(100);
  lcd.clear();
}


📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ วงจร