Noodlejay BlaBla

welcome and happy to share


發表留言

VS2019、C#使用Excel

開發環境:VS2019

作業系統:Win10

Excel版本:2010

加入參考Microsoft.Excel.14.Object.Library

加入namespace

using Microsoft.Office.Interop.Excel;

參考文章:

0000
https://learn.microsoft.com/zh-tw/previous-versions/office/troubleshoot/office-developer/automate-excel-from-visual-c


發表留言

SG90、Servo Motor伺服馬達、360度

SG90的結構如下,馬達搭配減速機構,以及可變電阻來達到定位控制。

電路板使用的IC為AA51880,能夠解調PWM訊號,達到定位控制,有興趣的人可以自行去找。

#360度版本:

無法控制定位,變成控制正反轉的轉速,連續旋轉。



#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(7);  // attaches the servo on pin 7 to the servo object
  Serial.begin(9600);
}

void loop() {
  myservo.write(0);  // CW 最快
  Serial.println("0");
  delay(2000);
  myservo.write(45); //CW
  Serial.println("45");
  delay(2000);
  myservo.write(90); // 停
  Serial.println("90");
  delay(2000);
  myservo.write(135);
  Serial.println("135"); //CCW
  delay(2000);
  myservo.write(180);
  Serial.println("180"); //CCW 最快
  delay(2000);

}

參考文章

https://www.upesy.com/blogs/tutorials/esp32-servo-motor-with-arduino-code-sg90#


發表留言

宜蘭兩日遊

Day1_

06:40 中壢出發
07:10 南港展覽館
08:29 蘇澳休息站
08:50 大薇家(等待猴子)
10:15 空氣島彈跳工廠(自助吧~提供飲料、食物(普通)、小美冰淇淋)
13:00 載大薇牽車
13:45 好樂迪(4H)
18:29 郁樂釣蝦場(公蝦2H、料理實力還行,不雷)
23:00 民宿(打麻將?)

Day2_
08:49 蘇澳無名肉包 (肉包售罄 干,菜包還行,粉漿蛋餅不錯)
09:30 蘇澳冷泉公園 (中午才放水?)
11:00 退房
11:15 翻割田甕缸雞(打團體戰?
12:59 出發台泥-星巴克和平門市 (到底…開5X分鐘)
(耍廢、聊天、打傳說)
18:12 出發奕順軒(翻割田甕缸雞)
18:44 羅東夜市旁奕順軒 (旁邊停車半小時免費、前面左轉宮廟停車 30/H 、嘟嘟房 50/H)
19:00 回程
20:00 南港
20:49 中壢


發表留言

C# .net HttpClient 替代HttpWebRequest

微軟建議用HttpClient Class替代HttpWebRequset類別

https://learn.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest?view=net-7.0

但是裡面.net framwork的範例,加了await等敘述 ? 而且不能執行??

using System;
using System.Net.Http;
 
public class Example
{
    public static void Main()
    {
        String url = "https://code.jquery.com/jquery-3.6.0.min.js";
 
        string s;
        using (HttpClient client = new HttpClient())
        {
            s = client.GetStringAsync(url).Result;
        }
 
        Console.WriteLine(s);
    }
}

#參考文章

https://www.techiedelight.com/zh-tw/fetch-contents-from-a-url-into-a-string-in-csharp/