Compare commits

..

No commits in common. "a37c3ba7f911cac56654cf8b32265c89a83e27fb" and "222e1c54ea950146044e520a1336114e113e0f1a" have entirely different histories.

3 changed files with 14 additions and 37 deletions

View File

@ -1,4 +1,7 @@
// const { SerialPort } = require('serialport')
// // Create a port
// const port = new SerialPort({
// path: '/com16/tty-usbserial1',
@ -13,28 +16,9 @@
// port.on('data', function (data) {
// console.log('Data:', data.toString('UTF8'))
// })
const http = require('node:http');
const { SerialPort } = require('serialport')
const { ReadlineParser } = require('@serialport/parser-readline')
const port = new SerialPort({ path: '/com16', baudRate: 9600 })
var str = "";
const port = new SerialPort({ path: '/com16/ROBOT', baudRate: 9600 })
const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' }))
parser.on('data', (data) => {
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);
parser.on('data', console.log)

9
sketch_mar22a.ino Normal file
View File

@ -0,0 +1,9 @@
int clockPin = 3; // Пин, соединённый с ножкой Clock
int resetPin = 2; // Пин, соединённый с ножкой Reset
void setup (){
Serial.begin(9600);
}
void loop (){
Serial.println("Привет!");
delay(1000);
}

View File

@ -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");
}
}