Sunday, 23 August 2020

Reset and Factory Setting Default HC05 and HC06

http://roboconshop.com/getattachment/1ce1c8ab-ee3f-4c79-82ce-8a97a5ddf536/FileName.aspx

https://www.thaieasyelec.com/downloads/EFDV390/EFDV390_Datasheet.pdf

https://www.instructables.com/id/Changing-Baud-Rate-of-HC-05-Bluetooth/

https://www.instructables.com/id/HOW-TO-HC-05-Bluetooth-MODULE-AT-Commands-With-But/

https://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/

(remove double quotes from AT command)

    To return HC-05 to mfg. default settings: "AT+ORGL"
    To get version of your HC-05 enter: "AT+VERSION?"
    To change device name from the default HC-05 to let's say MYBLUE enter: "AT+NAME=MYBLUE"
    To change default security code from 1234 to 2987 enter: "AT+PSWD=2987"
    To change HC-05 baud rate from default 9600 to 115200, 1 stop bit, 0 parity enter: "AT+UART=115200,1,0"

https://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/

Most useful AT commands are

AT : Ceck the connection.
AT+NAME : See default name
AT+ADDR : see default address
AT+VERSION : See version
AT+UART : See baudrate
AT+ROLE: See role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: see default password

Reset and Factory Setting Default

Thursday, 20 August 2020

Sunday, 9 August 2020

Arduino Calculator Serial Monitor

 arduino calculator serial monitor

 

https://www.youtube.com/watch?v=Wn3YvsU_IzE

Saturday, 8 August 2020

Voltmeter DC(0-25V)With Smartphone Display / Blynk / Nodemcu

 https://www.youtube.com/watch?v=AL0R-zff-Os

Making a Voltmeter

 

Making a Voltmeter

reference website


Interrupt Arduino

 https://www.youtube.com/watch?v=aBd4nFmVfBQ

Syntax and Command Arduino IncomingByte

 https://www.arduino.cc/reference/en/language/functions/communication/serial/available/

Arduino SD Card Module , to read SD card data then led on

 IncomingByte

https://www.arduino.cc/reference/en/language/functions/communication/serial/available/

upload below sketch then Serial Monitor

SD card text.txt file Example 88 then Serial Monitor to check will show56 

    // read from the file until there's nothing else in it:

    while (myFile.available()) {

      Serial.write(myFile.read());

    incomingByte = myFile.read();

    Serial.println(incomingByte,DEC);

    if (incomingByte == 56) {

    digitalWrite(ledG, HIGH);

    delay(10000);

    digitalWrite(ledG, LOW);

    delay(10000);

    }








/*SD卡

CS   --> to Arduino pin4 

SCK  --> to Arduino pin13

MOSI --> to Arduino pin11

MISO --> to Arduino pin12

VCC  --> to Arduino 5V

GND  --> to Arduino GND

*/

#include <SPI.h>

#include <SD.h>

File myFile;

String filename = "test.txt";     //要寫入的檔案名稱

int i = 0;

int ledG = 7; // 綠燈 正極 --> pin 7,  負極 --> GND 

int ledR = 8; // 紅燈 正極 --> pin 8,  負極 --> GND 

int incomingByte = 0;


void setup() {

  pinMode(ledR, OUTPUT); 

  pinMode(ledG, OUTPUT);

  pinMode(10,OUTPUT);    //保留pin10, SD Library需要使用

  

  Serial.begin(9600);

  while (!Serial) {}


  digitalWrite(ledR, HIGH);

  Serial.print("Initializing SD card...");  //SD卡初始化

  if (!SD.begin(4)) {

    Serial.println("initialization failed!");

    return;

  }

  Serial.println("initialization done.");

}


void loop()

{

  digitalWrite(ledG, HIGH);

  digitalWrite(ledR, LOW);


  /*


   此範圍可以加入其他程式碼



  */


  delay (3000);



  for (int i=0; i <= 10; i++){   //燈號警告,此段時間可以關閉電源、再拔除SD卡。

    digitalWrite(ledG, HIGH);

    delay(100);

    digitalWrite(ledG, LOW);

    delay(100);

  } 

  digitalWrite(ledR, HIGH);     //下面的程式是寫入SD卡,此段時間內請勿關閉電源、拔取SD卡。


  myFile = SD.open(filename, FILE_WRITE);

  if (myFile) {

    Serial.print("Writing to test.txt...");

    //myFile.print(millis());                   //寫入SD卡的時間,單位是1/1000秒。

    //myFile.print(",");

    

    //myFile.print("3");    //要寫入SD卡數據時,這一行請刪掉。

    

    //myFile.print(0);                  //要寫入SD卡數據時,請以逗號分隔數據。

    //myFile.print(",");

    //myFile.print(1);

    //myFile.print(",");

    //myFile.print(2);

    // ...

    //myFile.println();


    // close the file:

    myFile.close();

    Serial.println("done.");

  } else {

    // if the file didn't open, print an error:

    Serial.println("error opening test.txt");

  }

  // re-open the file for reading:

  myFile = SD.open(filename);

  if (myFile) {

    Serial.println("test.txt:");


    // read from the file until there's nothing else in it:

    while (myFile.available()) {

      Serial.write(myFile.read());

    incomingByte = myFile.read();

    Serial.println(incomingByte,DEC);

    if (incomingByte == 56) {

    digitalWrite(ledG, HIGH);

    delay(10000);

    digitalWrite(ledG, LOW);

    delay(10000);

    }

    

    }

    // close the file:

    myFile.close();

  } else {

    // if the file didn't open, print an error:

    Serial.println("error opening test.txt");

  }

  delay (3000);

}








ANOTHER Sketch


/*SD卡

CS   --> to Arduino pin4 

SCK  --> to Arduino pin13

MOSI --> to Arduino pin11

MISO --> to Arduino pin12

VCC  --> to Arduino 5V

GND  --> to Arduino GND

*/

#include <SPI.h>

#include <SD.h>

File myFile;

String filename = "test.txt";     //要寫入的檔案名稱

int i = 0;

int ledG = 8; // 綠燈 正極 --> pin 7,  負極 --> GND 

int ledR = 7; // 紅燈 正極 --> pin 8,  負極 --> GND 

int incomingByte = 0;


void setup() {

  pinMode(ledR, OUTPUT); 

  //pinMode(ledG, OUTPUT);

  pinMode(10,OUTPUT);    //保留pin10, SD Library需要使用

  

  Serial.begin(9600);

  while (!Serial) {}


  digitalWrite(ledR, HIGH);

  Serial.print("Initializing SD card...");  //SD卡初始化

  if (!SD.begin(4)) {

    Serial.println("initialization failed!");

    return;

  }

  Serial.println("initialization done.");

}


void loop()

{

  //digitalWrite(ledG, HIGH);

  digitalWrite(ledR, LOW);


  /*


   此範圍可以加入其他程式碼



  */


  delay (3);



  for (int i=0; i <= 10; i++){   //燈號警告,此段時間可以關閉電源、再拔除SD卡。

    //digitalWrite(ledG, HIGH);

    delay(100);

    //digitalWrite(ledG, LOW);

    delay(100);

  } 

  digitalWrite(ledR, HIGH);     //下面的程式是寫入SD卡,此段時間內請勿關閉電源、拔取SD卡。


  myFile = SD.open(filename, FILE_WRITE);

  if (myFile) {

    Serial.print("Writing to test.txt...");

    //myFile.print(millis());                   //寫入SD卡的時間,單位是1/1000秒。

    //myFile.print(",");

    

    //myFile.print("3");    //要寫入SD卡數據時,這一行請刪掉。

    

    //myFile.print(0);                  //要寫入SD卡數據時,請以逗號分隔數據。

    //myFile.print(",");

    //myFile.print(1);

    //myFile.print(",");

    //myFile.print(2);

    // ...

    //myFile.println();


    // close the file:

    myFile.close();

    Serial.println("done.");

  } else {

    // if the file didn't open, print an error:

    Serial.println("error opening test.txt");

  }

  // re-open the file for reading:

  myFile = SD.open(filename);

  if (myFile) {

    Serial.println("test.txt:");

pinMode(ledG, OUTPUT);

    // read from the file until there's nothing else in it:

    while (myFile.available()) {

      Serial.write(myFile.read());

    incomingByte = myFile.read();

    Serial.println(incomingByte,DEC);

    Serial.println(incomingByte,DEC);

hello:    

    if (incomingByte == 57) {

    digitalWrite(ledG, HIGH);

    delay(10000);

    goto hello;

    }

    

    }

    // close the file:

    myFile.close();

  } else {

    // if the file didn't open, print an error:

    Serial.println("error opening test.txt");

  }

  

}