GithubHelp home page GithubHelp logo

leamucho / serial_anything Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

Based on (I2C and SPI) Anything from Nick Gammon, a Serial version to send/receive anything! for Arduino

License: MIT License

C++ 100.00%

serial_anything's Introduction

Serial_Anything

Based on (I2C and SPI) Anything from Nick Gammon, a Serial version to send/receive anything! for Arduino based boards.

You should pay atention to the pins and corresponding number for the Serial connection you are going to use i.e. Serial, Serial1, Serial2, depending on the board you are using; and change the file accordingly. As normal connections from one board to the other,TX to RX, and RX to TX.

One side sending

#include "serial_Anything.h"

const int analogInPin = 0;
int sensorValue = 0;

void setup() {
  // initialize 
  Serial1.begin(115200);  
}

void loop() {
  sensorValue = analogRead(analogInPin);  
  serial_writeAnything(sensorValue);
  //no Serial.print because the forming byte inside the lib only works there, uncomment the line inside the .h file  
}

The other receiving

#include "serial_Anything.h"
int sensorValue = 0 ;

void setup() {
  // initialize both serial ports:
  //Serial.begin(9600); // Uncomment and change number the line below to check here on monitor
  Serial.begin(115200); // Serial to SerialX and also on the .h file 
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial.available()) { // Also to SerialX if monitor use 
    serial_readAnything(sensorValue);
    //Serial.println(sensorValue); //Uncomment to check the variable change on IDE monitor
  }
}

Be sure to not mess with the numbers of the serial ports if monitoring. You should check the 4.Communications/Multiserial example to see the use of various serials, whether on the examples on the IDE or Arduino site (link before).

BTW. Making tests, found one can use the same Serial port on IDE's monitor as with the pins, but be sure to disconnect before uploading your sketch (not tested on the receiving side, I might get confused KK).

Please check Nick Gammon's site, discussion on I2C and gitHub of the lib's this one is derived from.

Salut!!

serial_anything's People

Contributors

leamucho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.