This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
中華製 安デジタルノギスのデータを読み取ってUARTで送る。 | |
2016/04/19 7M4MON | |
24bitのデータで始めの20bitがValue。ただしはじめの16ビットしか使わなくていい(LSB first) | |
21ビット目が±、24ビット目がmm/インチ | |
Memory usage: ROM=57% なのでPIC12F629/675では力不足(RAM=21% - 41%) | |
↓をベースに色んなサイトのコードが混じっている | |
http://nut-bolt.nl/2012/reading-digital-calipers-with-an-arduino/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'METEX M-6000Mというテスターの読み取り文字列から、値を返すクラス。 | |
'https://github.com/ruimo/m6000m/blob/master/data.rb | |
'の移植。 | |
Public Class METEX | |
#Region "table" | |
'テーブルを定義。初期化子を使っているので.netFrameWork4.0(VS2010)以降対応。 | |
'移植元は「0x3b => :voltage,」のようにbyte型から変換していたので、 | |
'文字列→文字配列→文字コード変換すると素直に引用だと思う。 | |
'とりあえず書きなおすのが面倒なので、Asc(string)は使う方向。 | |
Dim function_table As New Dictionary(Of Integer, String) From { _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'RC-S620Sのチェックサムを返す | |
Function ByteAryToCheckSum(commandAry As Byte()) As Byte | |
Dim chkSumInt As Integer = 0 | |
For i = 0 To commandAry.Length - 1 | |
chkSumInt = chkSumInt + CInt(commandAry(i)) | |
Next | |
chkSumInt = 256 - chkSumInt Mod 256 | |
If chkSumInt = 256 Then chkSumInt = 0 | |
Return CByte(chkSumInt) | |
End Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************************** | |
STEPPER.C | |
ステッピングモーターをコントロールする | |
1つのユニポーラステッピングモーターをPORTBの0~3に接続。 | |
ボリュームかパルスで制御 | |
ボリュームは中点あたりでオフ、右に回すと右回転、左に回すと左回転 | |
パルス制御の場合、方向とパルスの2ピン使う | |
CCSのサンプルプログラムEX_STEP.CをベースにPIC16FF88向けに改造した。 | |
***********************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = require('express')(); | |
var http = require('http').Server(app); | |
var port = process.env.port || 1337; | |
var io = require('socket.io')(http); | |
var SerialPort = require('serialport').SerialPort; | |
var serial = new SerialPort('COM1', { //SZはCOM3 | |
baudrate: 9600 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LEDの色を選ぶ | |
var colorArray = ["#FF0000", "#00FF00", "#0000FF", "#00FFFF", "#FF00FF", "#FFFF00", "#FFFFFF"]; | |
var colorCommand = ["r", "t", "y", "u", "i", "o", "p"]; | |
var socket = io(); | |
socket.on('distance', function (data) { | |
$('h1').text(data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************robot.c********** | |
node-serialportから制御できるロボットを作るため | |
UART入力でモーターを制御する。 | |
追加機能でクラッカーを引く&超音波センサで距離を読み取る。 | |
*****************************************/ | |
#include <16F648A.h> | |
#fuses INTRC_IO,NOWDT,PUT,NOPROTECT,NOMCLR | |
#use delay(CLOCK = 4000000) //4MHz | |
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1) //ハードウェアUART |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Color を引数にとってHSVの値をダブル型の配列(3)として返す | |
' 2016/11/19 https://ja.wikipedia.org/wiki/HLS%E8%89%B2%E7%A9%BA%E9%96%93 を参考に白を近似色で選ぶように変更 | |
Function GetHSB(pColor As Color) As Double() | |
Dim hsbH As Double | |
Dim hsbS As Double | |
Dim hsbB As Double | |
With pColor | |
Dim rgbArray As Double() = {.R, .G, .B} | |
hsbH = .GetHue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IndexOfColorArray(colorArray As Color(), pixelColor As Color) As Integer | |
Dim colorIndex As Integer = -1 | |
For i = 0 To colorArray.Length - 1 | |
If pixelColor.R = colorArray(i).R And | |
pixelColor.G = colorArray(i).G And | |
pixelColor.B = colorArray(i).B And | |
pixelColor.A = colorArray(i).A Then | |
colorIndex = i | |
Exit For | |
End If |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ふみきりのオモチャ | |
* 2018/02/28 7M4MON | |
* Memory usage: ROM=19% RAM=16% - 19% | |
*/ | |
#include <12f683.h> // サーボを使うのでCCPモジュールがある683を選定 | |
#fuses INTRC_IO, NOWDT, PUT, NOPROTECT, NOMCLR, NOBROWNOUT | |
#use Delay(CLOCK=4000000) // 1cycle = 1us | |
#use fast_io(a) |
OlderNewer