雑感

2025年4月29日火曜日

ArduinoUnoR4Wifi(SDcard,PIEZO,DHT11,SERVO,CDS)



https://docs.sunfounder.com/projects/elite-explorer-kit/ja/latest/iot_projects/00_iot_project.html
un r4 wifi 日本語サイト

https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-dc-motor
r4の詳しい説明あり
-------------------------------------------------

 PIEZO,DHT11,SERVO,WS2812(真ん中が信号、赤Vcc、白Gnd)OK

ーーーーーーーーーーーーーーーーーーーーーーーーーー

https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-micro-sd-card

---------------- first :: file create on sdcard ----------------------

#include <SD.h>

#define PIN_SPI_CS 4 // The Arduino UNO R4 pin connected to the CS pin of SDcard module

File myFile;

void setup() {

  Serial.begin(9600);

  if (!SD.begin(PIN_SPI_CS)) {

    Serial.println(F("SD Card is either missing or has failed!"));

    while (1); // don't do anything more:

  }

  Serial.println(F("SD Card is ready"));

  if (!SD.exists("arduino.txt")) {

    Serial.println(F("arduino.txt doesn't exist. Creating arduino.txt file..."));

    // create a new file by opening a new file and immediately close it

    myFile = SD.open("arduino.txt", FILE_WRITE);

    myFile.close();

  }


  // recheck if file is created or not

  if (SD.exists("arduino.txt"))

    Serial.println(F("arduino.txt exists on SD Card."));

  else

    Serial.println(F("arduino.txt doesn't exist on SD Card."));

}


void loop() {

}

-----------------second :: data write (append) on sdcard--------------------------------------

#include <SD.h> #define PIN_SPI_CS 4 // The Arduino UNO R4 pin connected to the CS pin of SDcard module File myFile; void setup() { Serial.begin(9600); if (!SD.begin(PIN_SPI_CS)) { Serial.println(F("SD Card is either missing or has failed!")); while (1); // don't do anything more: } Serial.println(F("SD Card is ready")); // open file for writing myFile = SD.open("arduino.txt", FILE_WRITE); if (myFile) { myFile.println("Created by newbiely.com"); // write a line to Arduino myFile.println("Learn Arduino and SD Card"); // write another line to Arduino myFile.close(); } else { Serial.print(F("Error: Unable to open file arduino.txt")); } // open file for reading myFile = SD.open("arduino.txt", FILE_READ); if (myFile) { int line_count = 0; while (myFile.available()) { char line[100]; // maximum is 100 characters, change it if needed int line_length = myFile.readBytesUntil('\n', line, 100); // read line-by-line from Micro SD Card line_count++; Serial.print(F("Line ")); Serial.print(line_count); Serial.print(F(": ")); Serial.write(line, line_length); // print the character to Serial Monitor // \n character is escaped by readBytesUntil function Serial.write('\n'); // print a new line charactor } myFile.close(); } else { Serial.print(F("Error: Unable to open file arduino.txt")); } } void loop() { }

-------------third:: file read on sdcard------------------------------

#include <SD.h> #define PIN_SPI_CS 4 // The Arduino UNO R4 pin connected to the CS pin of SDcard module File myFile; void setup() { Serial.begin(9600); if (!SD.begin(PIN_SPI_CS)) { Serial.println(F("SD Card is either missing or has failed!")); while (1); // don't do anything more: } Serial.println(F("SD Card is ready")); // open file for writing myFile = SD.open("arduino.txt", FILE_WRITE); if (myFile) { myFile.println("Created by newbiely.com"); // write a line to Arduino myFile.println("Learn Arduino and SD Card"); // write another line to Arduino myFile.close(); } else { Serial.print(F("Error: Unable to open file arduino.txt")); } // open file for reading myFile = SD.open("arduino.txt", FILE_READ); if (myFile) { int line_count = 0; while (myFile.available()) { char line[100]; // maximum is 100 characters, change it if needed int line_length = myFile.readBytesUntil('\n', line, 100); // read line-by-line from Micro SD Card line_count++; Serial.print(F("Line ")); Serial.print(line_count); Serial.print(F(": ")); Serial.write(line, line_length); // print the character to Serial Monitor // \n character is escaped by readBytesUntil function Serial.write('\n'); // print a new line charactor } myFile.close(); } else { Serial.print(F("Error: Unable to open file arduino.txt")); } } void loop() { }

--------------- file delete is dangerous ---
単なるテキストファイルのremoveなのでsdcardからファイルを移してシェルでできる。。。

基本プロジェクト

センサー

  • フォトレジスタ
  • サーミスタ
  • 土壌湿度
  • チルトスイッチ
  • PIR動作センサーモジュール
  • 超音波
  • 湿度・温度センサーモジュール
  • RFID-RC522モジュール
  • GY-87 IMUモジュール

ディスプレイ

  • LEDモジュール
  • RGB LED
  • WS2812 RGB LEDストリップ
  • 7セグメントディスプレイ
  • I2C LCD1602
  • OLED

サウンド

  • アクティブブザー
  • パッシブブザー
  • オーディオモジュールとスピーカー

コントローラー

  • ボタン
  • ポテンショメータ
  • ジョイスティックモジュール
  • キーパッド
  • 赤外線レシーバー
  • MPR121

アクチュエーター

  • モーター
  • 水ポンプ
  • ステッピングモーター
  • サーボ
  • リレー

チップ

  • 74HC595
 
投稿者 fseigojp 時刻: 16:53
メールで送信BlogThis!X で共有Facebook で共有するPinterest に共有

0 件のコメント:

コメントを投稿

次の投稿 前の投稿 ホーム
登録: コメントの投稿 (Atom)

自己紹介

fseigojp
詳細プロフィールを表示

ブログ アーカイブ

  • ▼  2025 (127)
    • ►  11月 (15)
    • ►  10月 (17)
    • ►  9月 (7)
    • ►  5月 (41)
    • ▼  4月 (21)
      • ArduinoUnoR4Wifi(SDcard,PIEZO,DHT11,SERVO,CDS)
      • nodejs or go sqlite3 examples
      • go sqlite on ubuntu OK
      • go and firestore データ操作の成功例
      • Python3 or Nodejs uart to uno
      • unoR4wifiからuartでgoでdhtデータ受信(picocomで十分だが。。)
      • ArduinoUnoR4Wifi(dht11,rtc,L298,buzzer)
      • UNO TO GO VIA UART / go and firestore (最重要)
      • esp8266 led-server
      • Cloud Firestore 一応の到達点
      • Nodejs:: firebase firestore function
      • golang in raspi/gobot-firmata(led,lm35,servo)
      • NoJohnny5-Nodejs for RasPi::ledpwm,aqm0802,onoff/b...
      • raspberry pi :: nvm (nodejs and npm latest install...
      • Arduino R4 WiFi tutorial ウブンツで成功!
      • golang ubuntuついでにgobot-firmata成功
      • Kaluma(3)-esp01-AT (tutorial:connecting to internet)
      • FirebaseRtdb一応の到達点
      • Kaluma(2nd) speaker,tm1367,hcsr04,max7219,mcp3008,...
      • Nodejs :: xcratch/ cnako3 / Johynny5 &express&fbrt...
      • RasPicoWでfirebase-rtdb(単なるhttps get)
    • ►  3月 (13)
    • ►  2月 (5)
    • ►  1月 (8)
  • ►  2024 (62)
    • ►  12月 (3)
    • ►  11月 (2)
    • ►  10月 (1)
    • ►  9月 (2)
    • ►  8月 (3)
    • ►  7月 (6)
    • ►  6月 (9)
    • ►  5月 (7)
    • ►  4月 (4)
    • ►  3月 (9)
    • ►  2月 (9)
    • ►  1月 (7)
  • ►  2023 (51)
    • ►  12月 (4)
    • ►  11月 (5)
    • ►  10月 (4)
    • ►  9月 (2)
    • ►  8月 (2)
    • ►  7月 (8)
    • ►  6月 (3)
    • ►  5月 (4)
    • ►  4月 (5)
    • ►  3月 (5)
    • ►  2月 (4)
    • ►  1月 (5)
  • ►  2022 (44)
    • ►  12月 (2)
    • ►  11月 (6)
    • ►  10月 (4)
    • ►  9月 (2)
    • ►  8月 (4)
    • ►  7月 (4)
    • ►  6月 (3)
    • ►  5月 (4)
    • ►  4月 (5)
    • ►  3月 (1)
    • ►  2月 (3)
    • ►  1月 (6)
  • ►  2021 (26)
    • ►  12月 (5)
    • ►  11月 (5)
    • ►  10月 (4)
    • ►  9月 (1)
    • ►  8月 (2)
    • ►  7月 (2)
    • ►  6月 (1)
    • ►  5月 (2)
    • ►  3月 (1)
    • ►  2月 (1)
    • ►  1月 (2)
  • ►  2020 (16)
    • ►  12月 (1)
    • ►  11月 (2)
    • ►  10月 (3)
    • ►  9月 (1)
    • ►  8月 (1)
    • ►  7月 (2)
    • ►  6月 (2)
    • ►  5月 (2)
    • ►  4月 (1)
    • ►  3月 (1)
  • ►  2019 (11)
    • ►  12月 (1)
    • ►  11月 (2)
    • ►  10月 (4)
    • ►  4月 (1)
    • ►  2月 (2)
    • ►  1月 (1)
  • ►  2018 (13)
    • ►  12月 (1)
    • ►  8月 (1)
    • ►  7月 (1)
    • ►  5月 (2)
    • ►  2月 (1)
    • ►  1月 (7)
  • ►  2017 (32)
    • ►  12月 (2)
    • ►  11月 (1)
    • ►  10月 (2)
    • ►  9月 (1)
    • ►  7月 (1)
    • ►  6月 (2)
    • ►  5月 (4)
    • ►  4月 (18)
    • ►  2月 (1)
  • ►  2016 (24)
    • ►  11月 (2)
    • ►  10月 (2)
    • ►  9月 (3)
    • ►  8月 (1)
    • ►  7月 (1)
    • ►  6月 (3)
    • ►  5月 (5)
    • ►  4月 (5)
    • ►  3月 (2)
  • ►  2015 (10)
    • ►  11月 (1)
    • ►  10月 (2)
    • ►  6月 (1)
    • ►  5月 (1)
    • ►  4月 (1)
    • ►  2月 (2)
    • ►  1月 (2)
  • ►  2014 (8)
    • ►  9月 (5)
    • ►  8月 (1)
    • ►  4月 (1)
    • ►  3月 (1)
「シンプル」テーマ. Powered by Blogger.