Compare commits
No commits in common. "a37c3ba7f911cac56654cf8b32265c89a83e27fb" and "222e1c54ea950146044e520a1336114e113e0f1a" have entirely different histories.
a37c3ba7f9
...
222e1c54ea
26
index.js
26
index.js
@ -1,4 +1,7 @@
|
|||||||
// const { SerialPort } = require('serialport')
|
// const { SerialPort } = require('serialport')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // Create a port
|
// // Create a port
|
||||||
// const port = new SerialPort({
|
// const port = new SerialPort({
|
||||||
// path: '/com16/tty-usbserial1',
|
// path: '/com16/tty-usbserial1',
|
||||||
@ -13,28 +16,9 @@
|
|||||||
// port.on('data', function (data) {
|
// port.on('data', function (data) {
|
||||||
// console.log('Data:', data.toString('UTF8'))
|
// console.log('Data:', data.toString('UTF8'))
|
||||||
// })
|
// })
|
||||||
|
|
||||||
const http = require('node:http');
|
|
||||||
const { SerialPort } = require('serialport')
|
const { SerialPort } = require('serialport')
|
||||||
const { ReadlineParser } = require('@serialport/parser-readline')
|
const { ReadlineParser } = require('@serialport/parser-readline')
|
||||||
|
const port = new SerialPort({ path: '/com16/ROBOT', baudRate: 9600 })
|
||||||
const port = new SerialPort({ path: '/com16', baudRate: 9600 })
|
|
||||||
|
|
||||||
var str = "";
|
|
||||||
|
|
||||||
const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' }))
|
const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' }))
|
||||||
parser.on('data', (data) => {
|
parser.on('data', console.log)
|
||||||
if (str != data) {
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
str = data;
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Create a local server to receive data from
|
|
||||||
const server = http.createServer((req, res) => {
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(str);
|
|
||||||
});
|
|
||||||
|
|
||||||
server.listen(2048);
|
|
9
sketch_mar22a.ino
Normal file
9
sketch_mar22a.ino
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
int clockPin = 3; // Пин, соединённый с ножкой Clock
|
||||||
|
int resetPin = 2; // Пин, соединённый с ножкой Reset
|
||||||
|
void setup (){
|
||||||
|
Serial.begin(9600);
|
||||||
|
}
|
||||||
|
void loop (){
|
||||||
|
Serial.println("Привет!");
|
||||||
|
delay(1000);
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
#define PIN_INPUT 7 //вход7
|
|
||||||
|
|
||||||
|
|
||||||
void setup (){
|
|
||||||
Serial.begin(9600);
|
|
||||||
pinMode(PIN_INPUT, INPUT); //задаём вход
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop (){
|
|
||||||
if(digitalRead(PIN_INPUT) == HIGH) {
|
|
||||||
Serial.println("1");
|
|
||||||
} else {
|
|
||||||
Serial.println("0");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user