Forum > Embedded - AVR

Lazarus control Arduino Nano with Enc28J60

<< < (3/9) > >>

I am lost. Right now I want to start begin to make Lazarus working with Arduino Mega on USB. I just want to be to turn on and off on several LEDs. I don't know where to start or where we can find step by step.  Is there a tutorial where I can lean how to use LAzarus with Arduino Mega?


--- Quote from: microguy on May 28, 2017, 11:58:53 pm ---I am lost.
--- End quote ---
OK, then to get some confidence do the most simple thing first. Connect led to your Arduino using proper resistor. Light a led on and off using Arduino IDE for writing a very simple C program. Flash it to your Arduino and verify that the led blinks. After that use Arduino IDE to write another C program that listens to serial port to change led state with serial "on" and "off" commands. To test it use some terminal software, connect to proper serial port (check that port speed and other settings match Arduino port settings), and type on and off commands. Verify that Arduino led obeys your commands. For all this you can find a nice tutorial here:

All you need to do now is to make a Lazarus application that will send serial commands to Arduino like you did previously by hand with your terminal.

--- Quote from: microguy on May 28, 2017, 11:58:53 pm ---Is there a tutorial where I can lean how to use Lazarus with Arduino Mega?
--- End quote ---
There is not such tutorial that I am aware of, but your question can be split into two parts:
1) Make Arduino part. That's what I have just shown you how to do.
2) Make Lazarus part. This follows...

For Lazarus part make a form with 2 buttons, include Synaser unit and add Synapse package as a new requirement to your project. In OnClick event of both buttons put something like this:

--- Code: Pascal  [+][-]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";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  ser: TBlockSerial;begin  ser := TBlockSerial.Create;  try    ser.Connect('COM1'); // write here your USB virtual COM port number    Sleep(250);    ser.config(9600, 8, 'N', SB1, False, False);    ser.SendString('on' + #13#10); // button 2 should have 'off' here  finally;  end;end;
Compile. Enjoy. Have fun...  ::)

Nice topic!

Very understandable and clear!


--- Quote from: jb007 on May 29, 2017, 09:07:04 pm ---Nice topic!

Very understandable and clear!

--- End quote ---
You are so kind, so I felt motivated and created an initial Arduino wiki page:  ;)

Everyone feel free to expand and improve it.  ::)


Sorry for taking so long to respond. I was travel a lot for my company. I fiinlly be home few days. Anyway I got Arduino IDE working with Arduino Mega to turn on and off LED. Now I trying to get small Lazarus program that I create a button for one and another button for off. I think I am not sure how to use serial code and where do we put in Lazarus. Is there somewhere I can get more tutor on serial port on Lazarus or where I can download and already have source code and exe file that I can run?



[0] Message Index

[#] Next page

[*] Previous page

Go to full version