goo blog サービス終了のお知らせ 

Charry-charry工房(チャーリー・チャーリーコウボウ)

50歳の手習い
(県立秋田工業高校 機械科卒業後、40年目に自分用の旋盤・フライス盤を所有することに)

2024DEC30 センサーで動く猫(6)

2024-12-30 08:18:18 | arudino
ChatGPTと一緒にスケッチの改善
に奔走しておりますが、なかなか上手く
行かず。

センサーが動いているのかどうか?
LEDとかOLEDで確認しております。


なんとかOLEDに距離を表示させる事
は出来るようになりましたが、如何せん
タイヤが動かない?

これはデータがOLEDに横取りされた
からなのか????
良く分かりません。

今日は、ChatGPTではなく
GEMINIでトライしてみようかと
思います。

ChatGPTでインクルードするファイル
を取り替えてと言うと簡単に取り替えてくれ
たのには驚きました。

あんなに頭を悩ませていたのに。

諦めないで頑張ります。

部屋の温度は11.5度 寒い

明日はまた天気が悪そうです。




2024DEC27 arudino センサーで動く車3 と 熊 と DXCC

2024-12-27 09:26:26 | arudino
配線を見直したら走りだしました。

しかし、右回り専門
センサーを動かすサーボモーターの動き
もスムーズになりました。


さて、センサーの情報を基に左に回った
り・後退しないので、センサーの情報が
上手く伝わっていないのではないかと考
えております。

センサーが2個あったので、センサーが
壊れていないか試しましたが症状は同じ
でした。

こうなるとAIに相談するしかないかな?

と言うことで、今日も雷はないものの
強風が吹いているので、無線はお休みして

ARUDINOにトライしてみたいと思います。

〇熊
秋田市の仁井田にまた、熊が出てきました。
まだ、整備工場の中に居るようです。

朝ゴミを捨てるに行くときには護身用の棒
を持参しました。(笑)

〇ZB2KX
ARRLのLOTWを拝見したら
lotwに登録されてました。

これで
299になりました。
シエラレオネが登録されれば、晴れて
300となります。

いえーい!








2024DEC26  Arudino せンサー車

2024-12-26 09:14:21 | arudino
国際気象海洋株式会社hpのスクショ

雷注意報が出ているので、無線はお休み
午後3時頃からは大丈夫かな?

ARUDINOの車に電気を流してみました

サーボモーターは動くようです。
それ以外は動作しないので、配線を確認
してみたいと思います。


最初は右の車が動いていたのですが、ど
うも配線が違うのではないかと思いもう
一度作者のhpを見て図面を書いてみま
した。

まだ、間違っているかもしれません??
図面も最終的には綺麗にしたいと思いま
す。
現在の症状
モーターが動かない

と言う事でもう少しトラブルシューティ
ングを楽しみたいと思います。

いろいろなHPをネットサーフィンして
情報収集したいと思います。

ディジタルオシロで信号が出ているのか
を確認する必要がありそうです。




2023DEC05 arudino R4 wifi RTC NTP 時計

2023-12-05 14:31:34 | arudino
〇Arudino R4 WIFI
を購入したので、HPをネットサーフィン
したところ、時計の記事がありました。

プログラムをコピーして
Arudinoにインストールしたところ動きまし
た。

今日の先生は
小倉キャッスル一馬さん
https://ameblo.jp/ogura-castle/entry-12821772466.html
Arudino マイコンボードでの実験忘備録

注意することは
タイはUTCで時差7時間ですが、
日本は時差が9時間のためここを修
正する必要があります。
あとはWIFI機器のIDとパスワード
をプログラム上に記載する必要があります。

苦労もなく、Arudino が動いたのはLチカ
以外初めてです。(笑)

https://youtube.com/shorts/qlIt2S24RC4

プログラムを転載いたしました。

ーーーーープログラムーーーーーー

#include <WiFiS3.h>
#include "Arduino_LED_Matrix.h"
#include "RTC.h"


const char ssid[] = "**********"; //wifiのIDを入力 2.4Ghzと思われる
const char password[] = "**********"; // wifiのパスワードを入れる


WiFiUDP Udp;


#define timeZoneOffsetHours 7//タイは+7時間
RTCTime currentTime;


//スクロール時間
#define SCROLL_TIME 100 //ミリ秒
unsigned long tm = 0;


//LED Matrix用領域
byte matrix[200]; //文字列をドットに変換用
char DateTime[100]; //日時を文字列に変換用
int max_idx; //matrix配列の最終カラム
int secIdx; //matrix配列でどこから秒数表示か格納
int idx;
int secBack, minBack;


//LED matrix用のフォントを独自に作成
byte cfa[][6] PROGMEM = {
{'A', 0x7f, 0x88, 0x88, 0x7f}, //A
{'D', 0xff, 0x81, 0x81, 0x7e}, //D
{'E', 0xff, 0x91, 0x91, 0x91}, //E
{'F', 0xff, 0x90, 0x90, 0x90}, //F
{'H', 0xff, 0x10, 0x10, 0xff}, //H
{'I', 0x81, 0xff, 0x81}, //I
{'M', 0xff, 0x40, 0x30, 0x40, 0xff}, //M
{'N', 0xff, 0x60, 0x18, 0x06, 0xff}, //N
{'O', 0x7e, 0x18, 0x18, 0x7e}, //O
{'P', 0xff, 0x90, 0x90, 0x60}, //P
{'R', 0xff, 0x98, 0x94, 0x63}, //R
{'S', 0x62, 0x91, 0x91, 0x4e}, //S
{'T', 0x80, 0x80, 0xff, 0x80, 0x80}, //T
{'U', 0xfe, 0x01, 0x01, 0xfe}, //U
{'W', 0xf8, 0x07, 0x38, 0x07, 0xf8}, //W
{'0', 0x7e, 0x8d, 0xb1, 0x7e}, //0
{'1', 0x41, 0xff, 0x01}, //1
{'2', 0x67, 0x89, 0x91, 0x61}, //2
{'3', 0x46, 0x91, 0x91, 0x6e}, //3
{'4', 0x38, 0x48, 0xff, 0x08}, //4
{'5', 0xf2, 0x91, 0x91, 0x8e}, //5
{'6', 0x7e, 0x91, 0x91, 0x4e}, //6
{'7', 0xc0, 0x87, 0x98, 0xe0}, //7
{'8', 0x6e, 0x91, 0x91, 0x6e}, //8
{'9', 0x72, 0x89, 0x89, 0x7e}, //9
{'.', 0x03, 0x03}, // .
{'/', 0x03, 0x0c, 0x30, 0xc0}, // /
{':', 0x36, 0x36}, // :
{'-', 0x08, 0x08, 0x08, 0x08} }; // -


//曜日を数字から文字列に変換するテーブル
char dow[7][4] PROGMEM = {
{ "SUN" },
{ "MON" },
{ "TUE" },
{ "WED" },
{ "THU" },
{ "FRI" },
{ "SAT" }
};


void setup() {
byte packetBuffer[48];
int sts, i1;
turnLed(0, true);

RTC.begin();
turnLed(1, true);
WiFi.begin(ssid, password);
turnLed(2, true);
delay(3000);
while (WiFi.status() != WL_CONNECTED)
delay(500);
turnLed(3, true);


Udp.begin(2390);
turnLed(4, true);
memset(packetBuffer, 0, 48);
packetBuffer[0] = 0xE3; // LI, Version, Mode
packetBuffer[1] = 0; // Stratum, or type of clock
packetBuffer[2] = 6; // Polling Interval
packetBuffer[3] = 0xEC; // Peer Clock Precision
packetBuffer[12] = 49;
packetBuffer[13] = 0x4E;
packetBuffer[14] = 49;
packetBuffer[15] = 52;
turnLed(5, true);
delay(3000);


do{
sts = Udp.beginPacket("pool.ntp.org", 123); //NTP requests are to port 123
}while(!sts);
turnLed(6, true);
sts = Udp.write(packetBuffer, 48);
do{
sts = Udp.endPacket();
}while(!sts);
turnLed(7, true);


while(!Udp.parsePacket())
delay(500);
turnLed(8, true);
Udp.read(packetBuffer, 48); // read the packet into the buffer
unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
unsigned long secsSince1900 = highWord << 16 | lowWord;
unsigned long seventyYears = 2208988800UL;
unsigned long secondsSince1970 = secsSince1900 - seventyYears + (timeZoneOffsetHours * 3600);
turnLed(9, true);
RTCTime timeToSet = RTCTime(secondsSince1970);
RTC.setTime(timeToSet);
turnLed(10, true);


//disconnect WiFi as it's no longer needed
WiFi.disconnect();
turnLed(11, true);


RTC.getTime(currentTime);
turnLed(12, true);
for(i1 = 0; i1 < 11; i1++) //最初の11マスは空白
matrix[i1] = 0;
sprintf(DateTime, "%04d/%02d/%02d %s %02d:%02d:@%02d",
currentTime.getYear(),
Month2int(currentTime.getMonth()),
currentTime.getDayOfMonth(),
dow[(int)currentTime.getDayOfWeek()],
currentTime.getHour(),
currentTime.getMinutes(),
currentTime.getSeconds());
turnLed(13, true);
max_idx = setMatrixText(DateTime, 11);
turnLed(14, true);


secBack = currentTime.getSeconds();
minBack = currentTime.getMinutes();
idx = 0;


}


void loop() {
int ic1, ic2;


RTC.getTime(currentTime);
if(secBack != currentTime.getSeconds()){
char secStr[3];
sprintf(secStr, "%02d", currentTime.getSeconds());
setMatrixText(secStr, secIdx);
secBack = currentTime.getSeconds();
}


if(minBack != currentTime.getMinutes()){
sprintf(DateTime, "%04d/%02d/%02d %s %02d:%02d:@%02d",
currentTime.getYear(),
Month2int(currentTime.getMonth()),
currentTime.getDayOfMonth(),
dow[(int)currentTime.getDayOfWeek()],
currentTime.getHour(),
currentTime.getMinutes(),
currentTime.getSeconds());
max_idx = setMatrixText(DateTime, 11);
minBack = currentTime.getMinutes();
}


if(tm + SCROLL_TIME <= millis()) {
//格納場所をスライド、末端に到達したら始めに戻る
if (idx < max_idx)
idx++;
else{
idx = 0;
}


//経過時間を再計測
tm = millis();
}


//8x12LED View
for(ic1 = 0; ic1 < 8; ic1++){
for(ic2 = 0; ic2 < 12; ic2++){
turnLed(ic1 * 12 + ic2 , matrix[idx + ic2] >> (7 - ic1) & 0x01);
delayMicroseconds(20);
}
}
}


unsigned int setMatrixText(char* setStr, int setStart)
{
unsigned int srcf; //, setIdx;
int idx2, idx3 = 0;


while(setStr[idx3] != '\0'){
if(setStr[idx3] != ' ' && setStr[idx3] != '@')
for(srcf = 0; srcf < 29; srcf++)
if(setStr[idx3] == cfa[srcf][0])
break;
if(srcf >= 29) break;


switch(setStr[idx3]){ //文字をmtrixに変換
case '@': //秒の場所を取得
secIdx = setStart;
break;
case ' ':
for(idx2 = 0; idx2 < 3; idx2++){
matrix[setStart] = 0;
setStart++;
}
break;
case '.':
case ':':
for(idx2 = 0; idx2 < 2; idx2++){
matrix[setStart] = cfa[srcf][idx2 + 1];
setStart++;
}
break;
case 'I':
case '1':
for(idx2 = 0; idx2 < 3; idx2++){
matrix[setStart] = cfa[srcf][idx2 + 1];
setStart++;
}
break;
case 'M':
case 'N':
case 'T':
case 'W':
for(idx2 = 0; idx2 < 5; idx2++){
matrix[setStart] = cfa[srcf][idx2 + 1];
setStart++;
}
break;
default:
for(idx2 = 0; idx2 < 4; idx2++){
matrix[setStart] = cfa[srcf][idx2 + 1];
setStart++;
}
}
matrix[setStart] = 0;
setStart++;
idx3++;
}
for(idx2 = 0; idx2 < 11; idx2++)
matrix[setStart] = 0; //最後に余白を入れる


return setStart;
}



2023DEC04 arudino R4 wifi

2023-12-04 08:13:15 | arudino



〇Arudino

arudino R4 WIFIが昨日、1日遅れ
で到着しました。

光っているのは、既にSAVEされたプ
ログラムが動いている状況となります。

これからWIFIの設定とかブルートゥ
―スとかの設定をするつもりですが、意外
にYOUTUBEに掲載されていないので
HPをネットサーフィンすることにしたい
と思います。
また一つ、おもちゃが増えてしまった。
楽しみだな!

〇魚釣り
水曜日にならないと釣りはできないよう
です。この日は波が50cm位の予定なの
で期待できそうです。
「はたはた」来ないかな!!!!

〇無線 9L5M
18.095Mhzで入感している情報はある
ものの、私のところにはショートパスもロ
ングパスでも入感しません。だめだな!