Forum > Embedded - AVR
One-way serial communication example using Synaser & Arduino Nano
Aruna:
I am following this example on the wiki and the arduino sketch I modified slightly as shown below:
--- Code: C++ [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---void setup(){ pinMode(LED_BUILTIN, OUTPUT); // Set the default led as digital out, this way will work on *any* board uno, nano, mega // Start up serial connection Serial.begin(9600); // baud rate Serial.flush(); delay(1000); // give the port time to work } void loop() { String input = ""; // Read any serial input while (Serial.available() > 0) { input += (char) Serial.read(); // Read in one char at a time delay(5); // Delay for 5 ms so the next char has time to be received if (input == "on") { digitalWrite(LED_BUILTIN, HIGH); // on } else if (input == "off") { digitalWrite(LED_BUILTIN, LOW); // off } else if (input == "blink") { for (int i = 0; i <= 5; i++) { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for 0.5 seconds digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(500); } } }}
When I test the sketch using the arduino IDE's serial monitor everything works as expected.
When testing from Lazarus I see the 'RX' and 'L' led's on the nano flicker but the led does not come on and stay on. I have tried changing baud rates, no luck. Can use some help in how best to move forward with this please.
From past experience when the leds flicker that is usually a sign of baud rate mismatch but I could not get things to work :-(
MarkMLl:
--- Quote from: Aruna on September 21, 2024, 10:09:17 pm ---When testing from Lazarus I see the 'RX' and 'L' led's on the nano flicker but the led does not come on and stay on. I have tried changing baud rates, no luck. Can use some help in how best to move forward with this please.
From past experience when the leds flicker that is usually a sign of baud rate mismatch but I could not get things to work :-(
--- End quote ---
Check what you're doing to the control lines, in particular DTR which is usually connected to the Arduino's reset signal.
https://github.com/MarkMLl/ping-arduino-loader
MarkMLl
ccrause:
--- Quote from: MarkMLl on September 21, 2024, 11:30:16 pm ---Check what you're doing to the control lines, in particular DTR which is usually connected to the Arduino's reset signal.
--- End quote ---
Yes, this is a likely cause of the symptoms described.
Try disabling the DTR signal by inserting ser.DTR := false; before calling the Connect method(untested).
Aruna:
--- Quote from: MarkMLl on September 21, 2024, 11:30:16 pm ---Check what you're doing to the control lines, in particular DTR which is usually connected to the Arduino's reset signal.
--- End quote ---
Tried that already. No luck.
Aruna:
--- Quote from: ccrause on September 22, 2024, 08:12:34 am ---
--- Quote from: MarkMLl on September 21, 2024, 11:30:16 pm ---Check what you're doing to the control lines, in particular DTR which is usually connected to the Arduino's reset signal.
--- End quote ---
Yes, this is a likely cause of the symptoms described.
Try disabling the DTR signal by inserting ser.DTR := false; before calling the Connect method(untested).
--- End quote ---
Tried it, same error.
Navigation
[0] Message Index
[#] Next page