Sign in Join
Wiki copytemporary

Arduino/es: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Este artículo describe la manera de comunicar tu aplicación Lazarus/FPC con [Placas Arduino](https://en.wikipedia.org/wiki/Arduino). Esto abre un mundo completamente nuevo de sensores y actuadores físicos inteligentes para monitorización, control y adquisición de datos.
22
3-<figure>
4-<img src="Arduino_Uno_R3.png" title="Arduino_Uno_R3.png" />
5-<figcaption>Arduino_Uno_R3.png</figcaption>
6-</figure>
3+![](/wiki-images/6/6d/Arduino_Uno_R3.png)
74
85## Comunicación serie
96
107Aquí se muestra como comunicar con tu placa a través del canal de comunicación serie.
118
129### Lazarus side serial application
1310
1411Existen varias posibilidades para comunicaciones [[Hardware Access|serie]] en Lazarus/FPC.
1512
1613#### Minimal Lazarus Synaser serial example
1714
1815We will use [Synaser](http://synapse.ararat.cz/doc/help/synaser.html) from [Synapse library](http://www.ararat.cz/synapse/doku.php) in this example. Create Lazarus application with one form and two buttons. Include Synaser unit and add [[Synapse|Synapse package]] as a new requirement to your project. In OnClick event of both buttons put something like this:
1916
2017``` pascal
2118procedure TForm1.Button1Click(Sender: TObject);
2219var
2320 ser: TBlockSerial;
2421begin
2522 ser := TBlockSerial.Create;
2623 try
2724 ser.Connect('COM1'); // Escribe aquí el puerto COM asociado a la comunicación con Arduino(en linux es algo así como
2825 '/dev/ttyUSB0')
2926 Sleep(250);
3027 ser.config(9600, 8, 'N', SB1, False, False); // Establecemos los parámetros para la conexión Serie.
3128 ser.SendString('on'); // Enviamos la cadena 'on', El pulsador 2 debería tener aquí 'off'
3229 finally
3330 ser.free; // Liberamos los recursos tomados para TBlockSerial.
3431 end;
3532end;
3633```
3734
3835### Arduino side serial application
3936
4037You can program your Arduino in several languages.
4138
4239#### Minimal Arduino C sketch serial example
4340
4441You can follow [this](http://www.chrisbrand.co.za/2013/06/30/arduino-serial-port/) nice step by step tutorial. In short, you need to add a led with proper resistor to your input pin 13, compile this sketch in your [Arduino IDE](https://www.arduino.cc/en/Main/Software), and download it to your board:
4542
4643``` cpp
4744int led = 13; // Pin 13
4845
4946void setup()
5047{
5148 pinMode(led, OUTPUT); // Set pin 13 as digital out
5249
5350 // Start up serial connection
5451 Serial.begin(9600); // baud rate
5552 Serial.flush();
5653}
5754
5855void loop()
5956{
6057 String input = "";
6158
6259 // Read any serial input
6360 while (Serial.available() > 0)
6461 {
6562 input += (char) Serial.read(); // Read in one char at a time
6663 delay(5); // Delay for 5 ms so the next char has time to be received
6764 }
6865
6966 if (input == "on")
7067 {
7168 digitalWrite(led, HIGH); // on
7269 }
7370 else if (input == "off")
7471 {
7572 digitalWrite(led, LOW); // off
7673 }
7774}
7875```
7976
8077#### Minimal Arduino mikroPascal serial example
8178
8279[mikroPascal for AVR](https://www.mikroe.com/mikropascal/) can be used to develop Arduino programs. TBD.
8380
8481#### Minimal Arduino E-Lab AvrCo serial example
8582
8683[E-Lab AvrCo Multitasking Pascal](http://e-lab.de/AVRco/index_en.html) can be used to develop Arduino programs. TBD.
8784
8885#### Minimal Arduino FPC serial example
8986
9087Efectivamente, tu placa Arduino 8-bit AVR \[AVR Programming\|puede ser programada con FPC\]\] también. TBD.
9188
9289## Comunicación Ethernet
9390
9491Aquí mostramos como comunicar con la placa a través del canal de comunicación Ethernet.
9592
9693### Lazarus side ethernet application
9794
9895TBD
9996
10097### Arduino side ethernet application
10198
10299TBD
103100
104101## Resources
105102
106103[Forum topic that started this article](http://forum.lazarus.freepascal.org/index.php?topic=36885)
107104
108105[[AVR]]
109106
110107[[AVR Programming]]
111108
112109[Raspberry Pi Lazarus application talking to Arduino over serial](https://bigdanzblog.wordpress.com/2014/11/07/serial-communications-usb-between-a-raspberry-pi-and-an-arduino-using-lazarus-free-pascal/)
113110
114111[FPC application talking to ESP8266 over TCP](https://bigdanzblog.wordpress.com/2016/02/14/using-lazarus-free-pascal-to-communicate-with-esp8266/)
115112
116113[FPC application talking to Arduino Nano over TCP](https://bigdanzblog.wordpress.com/2014/11/19/tcp-communications-between-a-pc-and-an-arduino-nano-using-lazarus-free-pascal/)
117114
118115---
119116*From the Free Pascal wiki, page "Arduino/es", as it stood on 2020-02-09 after a change by GAN, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history