Skip to content

Instantly share code, notes, and snippets.

View notsobad's full-sized avatar

notsobad notsobad

View GitHub Profile
#include <PMS.h>
#include "PMS.h"
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//SoftwareSerial Serial1(10, 11); // RX, TX

关于串口(UART):

  1. 波特率表示每秒钟传输多少bit信息,如9600,则一bit约0.1ms,及100微秒左右,可以在示波器中看到
  2. 信息格式为0 + 8bit信息 + 奇偶校验位(可选),信息传输顺序为从低位到高位, 10000010 即为 01000001,即16进制的41,10进制的65,即字符A
  3. Arduino 只有一个串口Serial,想使用Serial1就要用SoftwareSerial
  4. 如果串口(0, 1)接了传感器,有可能会上传代码失败,这是把接的设备去掉即可
  5. 操作LCD设备,发现只有LiquidCrystal_I2C这个好用些,如果在循环在某一行中写数据,需要先clear,否则会重影
@notsobad
notsobad / gen8.md
Last active November 4, 2018 04:28
gen8
@notsobad
notsobad / fetch.js
Created July 22, 2018 12:30
Page parser using headless chrome.
const puppeteer = require('puppeteer');
const url = process.argv[2];
//console.log(url);
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url, {waitUntil: 'networkidle0'});
await page.waitFor(1500);
@notsobad
notsobad / egpu.md
Last active April 8, 2018 15:25
install cude on nuc with AORUS gtx 1070 gaming box

My setup:

  • NUC
  • AORUS gtx 1070 gaming box

It took me several days to install cuda, I have to reinstall nvidia driver、cuda、even  os serveral times. So I have some tips:

  • Read nvidia's cuda installation guide, Do not miss anything
  • Do not use the deb version of cude, Just use run file.
  • Install nvidia-390 driver first, then install cude by run file, it will ask you to install driver, say NO
/* Fri 11 Aug 2017 10:20:00 UTC */ ! function e(t, r, n) {
function a(i, c) {
if (!r[i]) {
if (!t[i]) {
var u = "function" == typeof require && require;
if (!c && u) return u(i, !0);
if (o) return o(i, !0);
var d = new Error("Cannot find module '" + i + "'");
throw d.code = "MODULE_NOT_FOUND", d
}
@notsobad
notsobad / add-soute.sh
Last active January 8, 2018 07:05
Add route table when you have both wi-fi and ethernet connected to different network.
#!/bin/bash
# if ethernet DOES NOT connected, remove route table
ifconfig en6 | grep 'inet 10.200.' || {
echo cleanup
sudo route delete 10.0.0.0/8 10.200.33.1
networksetup -setdnsservers Wi-Fi 114.114.114.114
networksetup -setsearchdomains Wi-Fi ''
exit 0
@notsobad
notsobad / awk-range.sh
Last active October 17, 2017 03:53
awk计算数据分布区间
awk 'BEGIN{
split("<10 10-100 100-500 500-100 >1000",b)
}{
if($2<10)a[1]++;
else if($2<100)a[2]++;
else if($2<500)a[3]++;
else if($2<1000)a[4]++;
else a[5]++
}END{