8

You cannot use Serial inside an interrupt. Transmitting Serial relies on interrupts being available, and from inside an interrupt they aren't. All Serial communication must be done from loop(). So you need to just count the switch toggles and check to see if that value has changed in your loop. volatile uint32_t toggles = 0; uint32_t old_toggles = 0; ...


5

I learned that I needed to include Arduino.h header file apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you. The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. ...


4

Yes, with a small converter board it can be connected to an Arduino. The "9 pin serial cable" is very likely an RS-232 interface. RS-232 is like UART with a few extra connections. Here is what the cable looks like: Basically UART with flow control and other modem lines. Most likely it hasn't any of them conencted but that standard RXD, TXD and GND. These ...


3

Is it possible to print the debug statements in the Serial window while the GPS module is connected to the hardware serial ports? Yes, that works. If you connect the Arduino TX pin 1 to the GPS RX, then everything you print to Serial goes to both the Serial Monitor window and the GPS device. This works, because: It's ok if you see the GPS configuration ...


3

Your chief problem is that FastLED turns off interrupts when sending the data. It does that because timing is critical, and with interrupts turned on that timing will get completely messed up. So with FastLED running repeatedly in a loop there is very little time when interrupts are enabled for reception to occur over SoftwareSerial. Unlike a real UART, ...


3

SoftwareSerial only works on a few select GPIO pins on the Mega. Specifically those pins that have PCINT on them. But that is irrelevant. There is no reason to use SoftwareSerial on a Mega except in exceptional circumstances. You have four hardware UARTs on the Mega, so there is no call to use SoftwareSerial. Use the real UART pins and objects: Serial -&...


2

This answer isn't going to give you the code to solve your problem, it is just ideas that you can look at and see what suits you best. You should be able to find an example on how to read from a serial connection, I'm sure there is at least one example in the IDE. You need to work out how to encode your data, having it in nice human friendly format (like ...


2

First, you could use a string for the commands. You just need to ensure there is some special char to mark the end of a command - like the newline char. Read the input from the port one char at a time, building the string as you go: char buffer[256]; uint16_t buffer_index = 0; void loop() { while (Serial.available()) { int c = Serial.read(); if ('\...


2

You could consider writing/reading the value to/from the EEPROM. http://arduino.cc/en/Reference/EEPROM This allows the board to be reset, or even turned off, and retain the value previously set. What you would be doing is saving the value to the internal memory of the Arduino. This is resettable and persistent over a "reboot". Granted, there is a ...


2

As Look Alterno wrote in a comment, you need to parse the incoming data on the receiving side. In this instance, you have to look for the line terminators. The Node.js serialport module provides a parser for this called Readline. Read that doc and use it.


2

It is an internal buffer and only the pointer gets increased. It it visible in the source code off the project, located on github: // Read data from buffer int SoftwareSerial::read() { if (!isListening()) return -1; // Empty buffer? if (_receive_buffer_head == _receive_buffer_tail) return -1; // Read from "head" uint8_t d = ...


2

Serial.print() feeds the data into the TX buffer one character at a time (through the Print class's inherited .write() function which HardwareSerial implements). If there isn't enough room in the TX buffer for the next character it waits for there to be room available. Characters are removed one at a time from the TX buffer and sent through the physical ...


2

The Arduino IDE's serial monitor is just one of many tools that can open a serial port and collect information from it. The first step is to make sure the data you are writing to the Serial object in the Arduino is in a format suitable for importing into Excel. Separate multiple values on one line with a comma "," or tab "\t" character. If you are running ...


2

First, you have to understand what “hex” means. Basically, you are representing binary data as text, where each byte is represented as two characters. For example, the number 42 is represented as either “2A” or “2a”. In C and C++, you can write this number as 0x2a, but I assume your serial stream sends the raw hex data, without the “0x” prefix. Thus, on the ...


2

You're thinking backwards. You don't want to read slower (which is what delay does), you want to only send every 10th entry. That is, count the lines as they come in. When you hit 10 you print one and reset your count. In other words: static int count = 0; if(newParoData == true){ count ++; if (count == 10) { count = 0; // (Why copy the ...


2

This is not a good tutorial. The receiver works by assuming 14 dotLen time periods for each character. There is a loop that runs 14 times, with a 200ms delay between each iteration. If the laser is detected, then a is incremented, otherwise f is incremented. This means that the sum of a and f is always 14, and the case where a==0 means nothing was ...


2

Read the values into an array big enough to store them Write the array with the write(const uint8_t *buffer, size_t size) method. Each write then gives you a block of binary data (512 values, 1024 bytes if they're 16-bit integers) written to the SD card. What you do with it then is up to you. Note: an Arduino UNO only has 2kB of memory. If you have 512 ...


2

Is it possible to program chips like the Arduino uno's Atmega328P directly with USB serial from your computer? The bare chip? Generally, no. Some chips that include USB hardware also may include a DFU bootloader in ROM. If your chosen chip has this, then yes you can - you just need to wire it up and use a suitable DFU firmware upload program to install ...


2

https://www.arduino.cc/reference/en/language/functions/communication/serial/availableforwrite/ availableForWrite Get the number of bytes (characters) available for writing in the serial buffer without blocking the write operation Write operations on Arduino streams wait if they can't write the data to output. You can use the count returned by ...


2

The line while (Serial.availableForWrite() <= 0) {} waits until the serial output buffer is not full. Whereas Serial.flush(); waits until the serial output buffer is empty.


1

I would use Stream class timed functions. Serial is implementation of Stream. The property timeout (setTimeout) sets how long will the blocking functions wait for the next byte/character. Default timeuot is 1000 ms. Timed functions of Stream are find, parseInt, parseFloat, readBytes, readBytesUntil, readString and readStringUntil. (Non blocking read ...


1

Since the length of each data varies, you should extract data using spererator like comma in the stream. First, get one data line from sensor. Read the string until the "Line feed(LF)" character or "Carriage Return(CR)" character appears. located at the end of line(EOL), these two characters seperates each string by changing line. Without these two ...


1

Are you sure the mouse is not sending a continuous stream of 1s? If that were the case then, because of buffering, all the 1s will serviced before the servo stops. For example, a sequence of 11111 followed by a 0 will cycle the movement 5 times before it stops and prints the 0.


1

NMEA sentences cannot be longer than 80 visible characters + terminators. Even with a CRLF, that's a max of 82 characters. You should be fine with a fixed-sized char array of 82.


1

I have seen this exact same problem, and it took me quite a while to track down the answer. The I2C protocol is a very raw protocol that is inexpensive to implement, but is very susceptible to noise on the bus. When I put the SCL and SDA lines on my oscilloscope, I saw that occasionally there were spikes of high frequency noise on both lines. These turned ...


1

The problem was the auto-reset of the Arduino, I disabled it. To disable, I connected a 10uf capacitor on the GND and RES. As in the image below:


1

The reasons it's not updating is because your code is sitting in the loop while (finished == false) {...} waiting for more json to arrive. Try replacing the while loop with something along these lines: while ((finished == false) || Serial.available()) { if (Serial.available()) { const char in = Serial.read(); if (in == '{') { response ...


Only top voted, non community-wiki answers of a minimum length are eligible