ESP32 腳位34 連接到可變電阻腳位 2
ESP32 腳位VIN 連接到可變電阻腳位 1
ESP32 腳位GND 毗連到可變電阻腳位 3
ESP32若何操縱可變電阻讀取外部電壓數值
ESP32若何操縱可變電阻讀取外部電壓數值

讀取數值為12 bits = 4096
0 - 4095

程式碼:

  1. const int potPin = 34;
  2. int val=0;
  3. void setup() {
  4.   Serial.begin(115200); //連線速度
  5.   delay(1000);
  6. }
  7.  
  8. void loop() {
  9.   // put your main code here, to run repeatedly:
  10.   val = analogRead(potPin); //讀取電壓數值
  11.   Serial.println(val); //印出電壓數值
  12.   delay(500); //延遲0.5秒
  13. }
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

有時辰會需要寫PHP程式去獲得指定資料夾內的檔案列表,這三個函式分別是glob、scandir、readdir
 
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

cxSelect 是基於jQuery 的多級聯動菜單插件,合用於省市、商品分類等聯動菜單。
列表數據經由過程AJAX 獲得,也能夠自定義,數據內容使用JSON 格局。
同時兼容Zepto,便利在移動端利用。
國內省市縣數據起原:basecss/cityData Date: 2014.03.31
全球首要城市數據起原:整理國內常用網站和軟件Date: 2014.07.29


版本:jQuery的V1.7 +的Zepto V1.0 +jQuery的cxSelect V1.4.0


利用方式载入 JavaScript 文件

文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

學會Arduino根基操控後
必然會想學會無線遙控,如藍芽Bluetooth, Wifi
這篇申明藍芽Bluetooth操控

結果圖
若何用藍芽Bluetooth連線節制 Arduino


影片


代碼:

  1. // Include necessary libraries
  2. #include <BLEDevice.h>
  3. #include <BLEServer.h>
  4. #include <BLEUtils.h>
  5. //#include <BLE2902.h>
  6. //#include <Wire.h>
  7.  
  8. // 定義 UUIDs (注意要與App Inventor內容對應)
  9. #define SERVICE_UUID            "C6FBDD3C-7123-4C9E-86AB-005F1A7EDA01"
  10. #define CHARACTERISTIC_UUID_RX  "B88E098B-E464-4B54-B827-79EB2B150A9F"
  11. #define CHARACTERISTIC_UUID_TX  "D769FACF-A4DA-47BA-9253-65359EE480FB"
  12.  
  13. // 界說LM35 ESP32 GPIO接腳
  14. const int analogIn = A0;
  15.   
  16. int RawValue= 0;
  17. double Voltage = 0;
  18. double tempC = 0;
  19. double tempF = 0;
  20. String BLE_Code;
  21. BLECharacteristic *pCharacteristic;
  22. bool deviceConnected = false;
  23. // Handle received and sent messages
  24. boolean ledState=false;
  25. String message = "";
  26. char incomingChar;
  27.  
  28. // Temperature Sensor 與led接腳變數
  29. float temperature = 0;
  30. const int ledPin = 2;
  31.  
  32. // 設定 callbacks onConnect & onDisconnect函數
  33. class MyServerCallbacks: public BLEServerCallbacks {
  34.   void onConnect(BLEServer* pServer) {
  35.     deviceConnected = true;
  36.   };
  37.   void onDisconnect(BLEServer* pServer) {
  38.     deviceConnected = false;
  39.   }
  40. };
  41.  
  42. // 設定 callback function 當收到新的資訊 (from the Android application)
  43. class MyCallbacks: public BLECharacteristicCallbacks {
  44.   void onWrite(BLECharacteristic *pCharacteristic) {
  45.     std::string rxValue = pCharacteristic->getValue();
  46.     BLE_Code="";
  47.     if(rxValue.length() > 0) {
  48.       Serial.print("接收資料為 : ");
  49.       for(int i = 0; i < rxValue.length(); i++) {
  50.         BLE_Code+=rxValue[i];
  51.         Serial.print(rxValue[i]);
  52.       }
  53.       Serial.println();
  54.       BLE_Code.toUpperCase();
  55.       Serial.println(BLE_Code);
  56.       if(BLE_Code.indexOf("LED")==0)
  57.       {
  58.         ledState=!ledState;
  59.       Serial.println(ledState);
  60.       }
  61.       if(BLE_Code.indexOf("ON")==0)
  62.       {
  63.         Serial.println("LED 點亮!");
  64.         ledState=true;
  65.       }
  66.       else if(BLE_Code.indexOf("OFF")==0) {
  67.         Serial.println("LED 熄滅!");
  68.         ledState=false;
  69.       }
  70.     }
  71.   }
  72. };
  73.  
  74. void setup() {
  75.   Serial.begin(115200);
  76.   pinMode(ledPin, OUTPUT);
  77.    
  78.   // 建立BLE Device
  79.   BLEDevice::init("ESP32_WeMos1");
  80.  
  81.   // 創設BLE Server
  82.   BLEServer *pServer = BLEDevice::createServer();
  83.   pServer->setCallbacks(new MyServerCallbacks());
  84.  
  85.   // 確立BLE Service
  86.   BLEService *pService = pServer->createService(SERVICE_UUID);
  87.  
  88.   // 建立BLE Characteristic
  89.   pCharacteristic = pService->createCharacteristic(
  90.                       CHARACTERISTIC_UUID_TX,
  91.                       BLECharacteristic::PROPERTY_NOTIFY);                     
  92. //  pCharacteristic->addDescriptor(new BLE2902());
  93.   BLECharacteristic *pCharacteristic = pService->createCharacteristic(
  94.                                          CHARACTERISTIC_UUID_RX,
  95.                                          BLECharacteristic::PROPERTY_WRITE);
  96. pCharacteristic->setCallbacks(new MyCallbacks());
  97.  
  98.   // 開始(起)service
  99.   pService->start();
  100.  
  101.   // 起頭(起)advertising
  102.   pServer->getAdvertising()->start();
  103.   Serial.println("等待BLE手機連線....");
  104.   
  105.   digitalWrite(ledPin,LOW);
  106.   delay(500);
  107.   digitalWrite(ledPin,HIGH);
  108.   delay(500);
  109.   digitalWrite(ledPin,LOW);
  110. }
  111.  
  112. void loop() {
  113.   // Check received message and control output accordingly
  114.     if (ledState)
  115.         digitalWrite(ledPin, HIGH);
  116.       else
  117.         digitalWrite(ledPin, LOW);
  118.   delay(20);
  119. }
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

之前碰到CPANEL發信給我


說磁碟空間不足


我心想4TB硬碟,沒幾個網站怎麼會空間不足


第一時候以為是網站被駭


到filezilla搜檢事後發現是PHP7.4 的LOG超大

Cpanel WHM 如何關閉PHP ERROR LOG

文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

註冊、設置好狐狸錢包後,如文內新增BSC鏈一般新增Arbitrum鏈網路。

網路名稱
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

在測試 mnist 數字辨識時

代碼起原
https://hackmd.io/@Maxlight/SkuYB0w6_#3-hyperparameter
 

  1. import torch
  2. from torch.utils import data as data_
  3. import torch.nn as nn
  4. from torch.autograd import Variable
  5. import matplotlib.pyplot as plt
  6. import torchvision
  7. import os
  8.  
  9. EPOCH = 1
  10. BATCH_SIZE = 50
  11. LR = 0.001
  12. DOWNLOAD_MNIST = False
  13.  
  14. train_data = torchvision.datasets.MNIST(root = './mnist',train = True,transform = torchvision.transforms.ToTensor(),download = DOWNLOAD_MNIST)
  15.  
  16. print(train_data.train_data.size())
  17. print(train_data.train_labels.size())
  18. plt.ion()
  19. for i in range(11):
  20.   plt.imshow(train_data.train_data[i].numpy(), cmap = 'gray')
  21.   plt.title('%i' % train_data.train_labels[i])
  22.   plt.pause(0.5)
  23. plt.show()
  24.  
  25. train_loader = data_.DataLoader(dataset = train_data, batch_size = BATCH_SIZE, shuffle = True,num_workers = 2)
  26.  
  27. test_data = torchvision.datasets.MNIST(root = './mnist/', train = False)
  28. test_x = torch.unsqueeze(test_data.test_data, dim = 1).type(torch.FloatTensor)[:2000]/255.
  29. test_y = test_data.test_labels[:2000]
  30.  
  31. class CNN(nn.Module):
  32.   def __init__(self):
  33.     super(CNN, self).__init__()
  34.     self.conv1 = nn.Sequential(
  35.         nn.Conv2d(in_channels = 1, out_channels = 16, kernel_size = 5, stride = 1, padding = 2,),# stride = 1, padding = (kernel_size-1)/2 = (5-1)/2
  36.         nn.ReLU(),
  37.         nn.MaxPool2d(kernel_size = 2),
  38.     )
  39.     self.conv2 = nn.Sequential(
  40.         nn.Conv2d(16, 32, 5, 1, 2),
  41.         nn.ReLU(),
  42.         nn.MaxPool2d(2)
  43.     )
  44.     self.out = nn.Linear(32*7*7, 10)
  45.  
  46.   def forward(self, x):
  47.     x = self.conv1(x)
  48.     x = self.conv2(x)
  49.     x = x.view(x.size(0), -1)
  50.     output = self.out(x)
  51.     return output, x
  52.  
  53. cnn = CNN()
  54. print(cnn)
  55.  
  56. optimization = torch.optim.Adam(cnn.parameters(), lr = LR)
  57. loss_func = nn.CrossEntropyLoss()
  58.  
  59. for epoch in range(EPOCH):
  60.   for step, (batch_x, batch_y) in enumerate(train_loader):
  61.     bx = Variable(batch_x)
  62.     by = Variable(batch_y)
  63.     output = cnn(bx)[0]
  64.     loss = loss_func(output, by)
  65.     optimization.zero_grad()
  66.     loss.backward()
  67.     optimization.step()
  68.  
  69.     if step % 50 == 0:
  70.         test_output, last_layer = cnn(test_x)
  71.         pred_y = torch.max(test_output, 1)[1].data.numpy()
  72.         accuracy = float((pred_y == test_y.data.numpy()).astype(int).sum()) / float(test_y.size(0))
  73.         print('Epoch: ', epoch, '| train loss: %.4f' % loss.data.numpy(), '| test accuracy: %.2f' % accuracy)
  74.  
  75. test_output, _ = cnn(test_x[:10])
  76. pred_y = torch.max(test_output, 1)[1].data.numpy()
  77. print(pred_y, 'prediction number')
  78. print(test_y[:10].numpy(), 'real number')
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

專家也是這麼做的網站SEO優化6步調
您的網站為何總是排名在後面呢?除了買告白之外,有無什麼撇步呢?網店日報來告知您,有哪些根基的SEO優化技能,做好這6個步驟,您的網站SEO就可以事半功倍!
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

最近電腦重灌WIN10
arduino重新安裝及設定
發現輸入開辟治理員網址時會呈現毛病

  1. https://dl.espressif.com/dl/package_esp32_index.json
文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()

假如已註冊過,想查詢本身的公私鑰:
https://www.google.com/recaptcha/admin#list
還沒註冊過的,下面三步調設立建設Google reCAPTCHA~


 

文章標籤

zolanddelbs 發表在 痞客邦 留言(0) 人氣()