Sign in Join
Wiki copytemporary

Arduino/es: what changed

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

Title: Arduino/es

OldNewLine
1+Este 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.
2+
3+<figure>
4+<img src="Arduino_Uno_R3.png" title="Arduino_Uno_R3.png" />
5+<figcaption>Arduino_Uno_R3.png</figcaption>
6+</figure>
7+
8+## Comunicación serie
9+
10+Aquí se muestra como comunicar con tu placa a través del canal de comunicación serie.
11+
12+### Lazarus side serial application
13+
14+Existen varias posibilidades para comunicaciones [[Hardware Access|serie]] en Lazarus/FPC.
15+
16+#### Minimal Lazarus Synaser serial example
17+
18+We 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:
19+
20+``` pascal
21+procedure TForm1.Button1Click(Sender: TObject);
22+var
23+ ser: TBlockSerial;
24+begin
25+ ser := TBlockSerial.Create;
26+ try
27+ ser.Connect('COM1'); // Escribe aquí el puerto COM asociado a la comunicación con Arduino(en linux es algo así como
28+ '/dev/ttyUSB0')
29+ Sleep(250);
30+ ser.config(9600, 8, 'N', SB1, False, False); // Establecemos los parámetros para la conexión Serie.
31+ ser.SendString('on'); // Enviamos la cadena 'on', El pulsador 2 debería tener aquí 'off'
32+ finally
33+ ser.free; // Liberamos los recursos tomados para TBlockSerial.
34+ end;
35+end;
36+```
37+
38+### Arduino side serial application
39+
40+You can program your Arduino in several languages.
41+
42+#### Minimal Arduino C sketch serial example
43+
44+You 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:
45+
46+``` cpp
47+int led = 13; // Pin 13
48+
49+void setup()
50+{
51+ pinMode(led, OUTPUT); // Set pin 13 as digital out
52+
53+ // Start up serial connection
54+ Serial.begin(9600); // baud rate
55+ Serial.flush();
56+}
57+
58+void loop()
59+{
60+ String input = "";
61+
62+ // Read any serial input
63+ while (Serial.available() > 0)
64+ {
65+ input += (char) Serial.read(); // Read in one char at a time
66+ delay(5); // Delay for 5 ms so the next char has time to be received
67+ }
68+
69+ if (input == "on")
70+ {
71+ digitalWrite(led, HIGH); // on
72+ }
73+ else if (input == "off")
74+ {
75+ digitalWrite(led, LOW); // off
76+ }
77+}
78+```
79+
80+#### Minimal Arduino mikroPascal serial example
81+
82+[mikroPascal for AVR](https://www.mikroe.com/mikropascal/) can be used to develop Arduino programs. TBD.
83+
84+#### Minimal Arduino E-Lab AvrCo serial example
85+
86+[E-Lab AvrCo Multitasking Pascal](http://e-lab.de/AVRco/index_en.html) can be used to develop Arduino programs. TBD.
87+
88+#### Minimal Arduino FPC serial example
89+
90+Efectivamente, tu placa Arduino 8-bit AVR \[AVR Programming\|puede ser programada con FPC\]\] también. TBD.
91+
92+## Comunicación Ethernet
93+
94+Aquí mostramos como comunicar con la placa a través del canal de comunicación Ethernet.
95+
96+### Lazarus side ethernet application
97+
98+TBD
99+
100+### Arduino side ethernet application
101+
102+TBD
103+
104+## Resources
105+
106+[Forum topic that started this article](http://forum.lazarus.freepascal.org/index.php?topic=36885)
107+
108+[[AVR]]
109+
110+[[AVR Programming]]
111+
112+[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/)
113+
114+[FPC application talking to ESP8266 over TCP](https://bigdanzblog.wordpress.com/2016/02/14/using-lazarus-free-pascal-to-communicate-with-esp8266/)
115+
116+[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/)
117+
118+---
119+*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