New answers tagged

0

You are trying to use the serial port connected to two devices at a time: to the on-board serial/USB bridge that allows communication with your computer some unspecified external serial device. Connecting your TX (transmit pin) to two receivers is fine: whatever you write will be received by both. Connecting your RX to two transmitters doesn't work, you ...


1

I can not comment, it turns out that this example that you are working is not very suitable, since the RX and TX are directly connected to the USB connection (for Arduino UNO), that is, you can only use these pins as long as it is loaded from Sketch uses An external power supply to connect the Arduino, my recommendation is to work if you have a sensor to ...


4

This manual page of strlcpy() is quite clear: If the src and dst strings overlap, the behavior is undefined. This means you should avoid it, even if it works on some tests. The advice you got of just trying is not good advice. Use memmove() instead.


0

C has an "Exclusive Or" operator which is ^. You can use that instead of | so that it toggles the bit rather than always setting it: case 'A' : bt_leds_activated ^= 1; break; With ^ if you OR a 0 with a 1 you get a 1. If you OR a 0 with a 0 you get a 0. If you OR a 1 with a 1 you get a 0. That means every time you send A bit one of ...


0

in loop() replace digitalWrite(led1,LOW); with if (newTime - oldTime >= dt){ digitalWrite(led1,LOW); } and you can remove the else if(oldTime-newTime >= dt){ oldTime=newTime; digitalWrite(led1,LOW); } from the for loop


1

Old time and new time are wrong way round on a part where the LED'd are switched off else if(oldTime-newTime >= dt){ oldTime=newTime; digitalWrite(led1,LOW); } When simple processors reach the max or min value and continue counting, they overflow and start counting from far end: So 5-8=maxint(largest number)-3 Result is that ...


0

The problem was in the serialEvent() method. I did not rest the bufferindex where i red the received message so it allways stayed there until the arduino ran out of memory and also i did not gave the arduino enough time to receive the message so i added delay(1) there. Here is my updated code: void serialEvent() { inputBufferLength = 0; sendPosition = ...


0

Every time you receives data, it tries to read a full line (SerialPort.ReadLine()). If there's not a full line available, it will block the current thread until there is or until it times out. These calls will stack up and eventually cause the application to fail.


5

Using #include <Arduino.h> in your myheader.h will also include <stdint.h> and probably solve this. The Arduino IDE automatically includes Arduino.h in the sketch itself, but apparently not for external stuff.


Top 50 recent answers are included