{"id":20852746,"url":"https://github.com/wms784/arduino","last_synced_at":"2026-04-22T15:36:59.817Z","repository":{"id":130818698,"uuid":"459042055","full_name":"WMs784/Arduino","owner":"WMs784","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-14T14:23:38.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T05:05:35.156Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WMs784.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T06:28:01.000Z","updated_at":"2022-02-17T15:45:25.000Z","dependencies_parsed_at":"2023-05-18T21:00:38.504Z","dependency_job_id":null,"html_url":"https://github.com/WMs784/Arduino","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WMs784/Arduino","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WMs784%2FArduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WMs784%2FArduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WMs784%2FArduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WMs784%2FArduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WMs784","download_url":"https://codeload.github.com/WMs784/Arduino/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WMs784%2FArduino/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32143661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T15:33:03.595Z","status":"ssl_error","status_checked_at":"2026-04-22T15:30:42.712Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T03:18:44.908Z","updated_at":"2026-04-22T15:36:59.791Z","avatar_url":"https://github.com/WMs784.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arduino 先遣ローバー\n\n## 環境\n- AVR Boards 1.8.2 ← ArduinoSTLを使うためにダウングレード（デフォルトは1.8.3）\n- Arduino Uno, Arduino IDE 1.8.19, 書き込み先 \"/dev/tty.usbmodem14101\"\n### 使用ライブラリ\n- ArduinoSTL.h\n- I2Cdev\n- MPU6050\n\n## CAUTION!\n- Arduinoはvectorを扱えない\n\n## Note\n- 経路探索はグリッドグラフにおける幅優先探索により行う(無向グラフは用いない)．\n- なるべく曲がる回数が少なくなるようにというのも考慮したほうが良い．曲がった後の距離を短く\n- ローバの方向転換時のモータ制御は磁気センサからのデータに従う．→ 応答性の問題から特別な制御が必要かも：時間で考えた方が良い\n- 進む距離はロータリーエンコーダの値を参照しながら前進．\n\n\n## Task\n- mapは確率変数で管理すると精度上がりそう\n- 統計的な誤差のキャリブレーション\n\n## Memo\n- 角位置センサの設定読み込みにすごく時間がかかっている\n→ おそらくコードどっか間違ってるかも．要確認！\n\n## sample code by michi\n```total1.ino\n// LED\nconst int RED = A0;\nconst int BLUE = A1;\nconst int GREEN = A2;\n// DCモータ\nconst int motor11 = 3;\nconst int motor12 = 4;\nconst int motor21 = 5;\nconst int motor22 = 6;\n// サーボモータ\n#include \u003cServo.h\u003e\nServo myservo;\nconst int SV_PIN = 9;\n// ロータリーエンコーダ\nconst int pinA = 7;\nconst int pinB = 8;\nint encoderPosCount = 0;\nint pinALast;\nint aVal;\nboolean bCW;\n// 超音波センサ\nconst int trigPin = 11;\nconst int echoPin = 12;\ndouble duration = 0;\ndouble distance = 0;\n//　水位センサ\nconst int sensorPin = A3; //sensor pin connected to analog pin A0\nint liquid_level;\nvoid setup()\n{\n  Serial.begin(9600);\n  // LED\n  pinMode(GREEN, OUTPUT);\n  pinMode(BLUE, OUTPUT);\n  pinMode(RED, OUTPUT);\n  //モータ\n  pinMode(motor11, OUTPUT);\n  pinMode(motor12, OUTPUT);\n  pinMode(motor21, OUTPUT);\n  pinMode(motor22, OUTPUT);\n  //サーボ\n  myservo.attach(SV_PIN, 500, 2400);  // サーボの割当(パルス幅500~2400msに指定)\n  //ロータリエンコーダ\n  pinMode (pinA, INPUT);\n  pinMode (pinB, INPUT);\n  pinALast = digitalRead(pinA);\n  //超音センサ\n  pinMode(trigPin, OUTPUT);\n  pinMode(echoPin, INPUT);\n  //水位センサ\n  pinMode(sensorPin, INPUT);\n}\nvoid loop() {\n  //LEDをセンシング中の緑に\n  digitalWrite(GREEN, HIGH);\n  //超音波距離センサとサーボ\n  for ( int i = 0; i \u003c 6; i++) {\n    for ( int j = 0; j \u003c 100; j++) {\n      digitalWrite(trigPin, LOW);\n      digitalWrite(echoPin, LOW);\n      delayMicroseconds(1);\n      digitalWrite(trigPin, HIGH);\n      delayMicroseconds(10);\n      digitalWrite(trigPin, LOW);\n      duration = pulseIn(echoPin, HIGH);\n      distance += duration * 0.000001 * 34000 / 2;\n    }\n    digitalWrite(trigPin, LOW);\n    digitalWrite(echoPin, LOW);\n    distance = distance * 0.01;//１００個の平均を取る\n    Serial.print(\"distance \");\n    Serial.print(distance);\n    Serial.print(\"angle \");\n    Serial.println(i * 30);\n    myservo.write(i * 30);  // サーボモーターを30i度の位置まで動かす\n    delay(2000);\n  }\n  //LEDを移動中の青に\n  digitalWrite(GREEN, LOW);\n  digitalWrite(BLUE, HIGH);\n  //移動開始\n  digitalWrite(motor12, LOW);\n  digitalWrite(motor11, HIGH);\n  //エンコーダの値読み取り、モータの動きは適当\n  int encoderPosCount = 0;\n  while (encoderPosCount \u003c 10) {\n    aVal = digitalRead(pinA);\n    if (aVal != pinALast) {\n      if (digitalRead(pinB) != aVal) {\n        encoderPosCount ++;\n      }\n      else {\n        encoderPosCount--;\n      }\n      Serial.print(\"Encoder Position: \");\n      Serial.println(encoderPosCount);\n    }\n    pinALast = aVal;\n  }\n  digitalWrite(motor12, HIGH);\n  digitalWrite(motor11, LOW);\n  delay(5000);\n  digitalWrite(motor12, LOW);\n  digitalWrite(motor11, LOW);\n  digitalWrite(motor21, HIGH);\n  digitalWrite(motor22, LOW);\n  while ((encoderPosCount \u003c 20) \u0026\u0026 (encoderPosCount \u003e= 10)) {\n    aVal = digitalRead(pinA);\n    if (aVal != pinALast) {\n      if (digitalRead(pinB) != aVal) {\n        encoderPosCount ++;\n      }\n      else {\n        encoderPosCount--;\n      }\n      Serial.print(\"Encoder Position: \");\n      Serial.println(encoderPosCount);\n    }\n    pinALast = aVal;\n  }\n  digitalWrite(motor22, HIGH);\n  digitalWrite(motor21, LOW);\n  delay(5000);\n  digitalWrite(motor21, LOW);\n  digitalWrite(motor22, LOW);\n  digitalWrite(BLUE, LOW);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwms784%2Farduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwms784%2Farduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwms784%2Farduino/lists"}