summaryrefslogtreecommitdiff
path: root/OpenModelica_Arduino_With_MDD/Arduino.mo
blob: 649b694438c1d92058c7ff9ad2bb1b270dbe5848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
package Arduino
  extends Arduino.SerialCommunication.Icons.GenericICPackage;

  package SerialCommunication "Serial Communication Package for Arduino"
    extends Arduino.SerialCommunication.Icons.FunctionLayerIcon;
    import ModelicaReference.Operators;

    package Functions
      extends Modelica.Icons.Package;
      import Modelica;

      function open_serial "Command to initialize the serial port which is connected to Arduino"
        extends Modelica.Icons.Function;
        input Integer handle, port, baudrate;
        output Integer OK;
      
        external OK = open_serial(handle, port, baudrate) annotation(
          Library = "SerialComm");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>open_serial</b>(handle,port,baudrate);
</pre></blockquote>
<h4>Description</h4>
<p>
Establishes a serial communication using port number \"port\".To connect to the Arduino board, check the port number from the device manager or check it from the Arduino software.
</p>
</html>"));
      end open_serial;

      function read_serial "read characters from serial port"
        extends Modelica.Icons.Function;
        input Integer handle;
        input Integer size;
        output Integer r_OK;
      protected
        Integer buf[size + 1];
        //String buf;
      
        external r_OK = read_serial(handle, buf, size) annotation(
          Library = "SerialComm");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>read_serial</b>(handle,size);
</pre></blockquote>
<h4>Description</h4>
<p>The translation setting of openserial can come in the way, affecting the number of characters effectively read. If that is the case, omitting the parameter n might be a bad idea, as scilab can hang. This would happen if the input stream contains CR or LF characters which are filtered out: in such cases serialstatus counts them, but readserial does not see them and keeps wating (if the blocking mode of openserial was true) until the total number is received.
</p>
</html>"));
      end read_serial;

      //algorithm
      //Modelica.Utilities.Streams.print(String(buf));

      function write_serial "write to the serial port"
        extends Modelica.Icons.Function;
        input Integer handle;
        input String str;
        input Integer size;
        output Integer w_OK;
      
        external w_OK = write_serial(handle, str, size) annotation(
          Library = "SerialComm");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>write_serial</b>(handle,str,size);
</pre></blockquote>
<h4>Description</h4>
<p>No end of line character is appended to the string; the user might have to add it if the device being talked to requires it. The Tcl command puts -nonewline is used. In addition, the translation mode of openserial can come into way.
</p>
</html>"));
      end write_serial;

      function close_serial "Command to close the serial port which is connected to Arduino"
        extends Modelica.Icons.Function;
        input Integer handle;
        output Integer c_OK;
      
        external c_OK = close_serial(handle) annotation(
          Library = "SerialComm");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>close_serial</b>(handle);
</pre></blockquote>
<h4>Description</h4>
<p>Closes the port for serial communication specified by \"handle\".It is important to close the serial port after use, else the port would be busy and restart of Scilab might required to connect to it again.
</p>
</html>"));
      end close_serial;

      function status_serial "get status of the serial port"
        extends Modelica.Icons.Function;
        input Integer handle;
        output Integer stat_OK;
      protected
        Integer bytes[2];
      
        external stat_OK = status_serial(handle, bytes) annotation(
          Library = "SerialComm");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>status_serial</b>(handle);
</pre></blockquote>
<h4>Description</h4>
<p>Provides status of serial communication channel specified by \"handle\".Get some information about the number of characters present in the input and output buffers of the serial port, and about the status lines (DTS, CTS, etc.).The translation setting of openserial can come in the way. If the input stream contains CR or LF characters which are filtered out, openserial counts them but readserial does not see them.
</p>
</html>"));
      end status_serial;

      function cmd_digital_out "Command to sent out digital signal to a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no, val;
        output Integer digital_w_OK;
      
        external digital_w_OK = cmd_digital_out(h, pin_no, val) annotation(
          Library = "Digital");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>cmd_digital_out</b>(handle,pin_no,value);
</pre></blockquote>
<h4>Description</h4>
<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component.
To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage.
</p>
</html>"));
      end cmd_digital_out;

      function cmd_digital_in "Command to read in digital signal from a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no;
        output Integer digital_in;
      
        external digital_in = cmd_digital_in(h, pin_no) annotation(
          Library = "Digital");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>cmd_digital_in</b>(handle,pin_no);
</pre></blockquote>
<h4>Description</h4>
<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component.
To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage.
</p>
</html>"));
      end cmd_digital_in;

      function delay "Provides delay.Suspends Openmodelica."
        extends Modelica.Icons.Function;
        input Integer t;
      
        external delay(t) annotation(
          Library = "delay");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>delay</b>(milliseconds);
  </pre></blockquote>
  <h4>Description</h4>
  <p>Delay process for specified number of miliseconds specified by the argument. The actual suspension time may be longer because of other activities in the system, or because of the time spent in processing the call.
  </p>
  </html>"));
      end delay;

      function cmd_analog_in "Command to read in analog signal from a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no;
        output Integer val;
      
        external val = cmd_analog_in(h, pin_no) annotation(
          Library = "Analog");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>cmd_analog_in</b>(handle,pin_no);
</pre></blockquote>
<h4>Description</h4>
<p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023.
</p>
</html>"));
      end cmd_analog_in;

      function cmd_analog_out "Command to sent out analog signal to a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no;
        input Real val;
        output Integer analog_w_OK;
      
        external analog_w_OK = cmd_analog_out(h, pin_no, val) annotation(
          Library = "Analog");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>cmd_analog_out</b>(handle,pin_no,val);
</pre></blockquote>
<h4>Description</h4>
<p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage.
The input port accepts the value from 0 to 255 which is correspoding to the duty cycle of 0 to 100%. In other words, sending 0 to the block will generate 0 V output at the port, 127 generates 2.5V and 255 generates 5V. (the port is 8 bits, so the resolutions of output would be 2^8 =256).
</p>
</html>"));
      end cmd_analog_out;

      function cmd_analog_in_volt "Command to read in analog signal from a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no;
        output Integer val;
      
        external val = cmd_analog_in_volt(h, pin_no) annotation(
          Library = "Analogv");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>cmd_analog_in_volt</b>(handle,pin_no);
  </pre></blockquote>
  <h4>Description</h4>
  <p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023. This function scale the reading to 0-5 so the user could get the measured voltage directly.
  </p>
  </html>"));
      end cmd_analog_in_volt;

      function cmd_analog_out_volt "Command to sent out analog signal to a connected Arduino board"
        extends Modelica.Icons.Function;
        input Integer h, pin_no;
        input Real val;
        output Integer analog_v_wOK;
      
        external analog_v_wOK = cmd_analog_out_volt(h, pin_no, val) annotation(
          Library = "Analogv");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>cmd_analog_out_volt</b>(handle,pin_no,val);
  </pre></blockquote>
  <h4>Description</h4>
  <p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage.
  </p>
  </html>"));
      end cmd_analog_out_volt;

      function cmd_dcmotor_setup "Command to setup pins to control DC motor"
        extends Modelica.Icons.Function;
        input Integer handle, driver_type, motor_no, pin1, pin2;
      
        external cmd_dcmotor_setup(handle, driver_type, motor_no, pin1, pin2) annotation(
          Library = "DCMotor");
        annotation(
          Documentation(info = "<html>
      <h4>Syntax</h4>
      <blockquote><pre>
      Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_setup</b>(handle,driver_type,motor_no,pin_no1,pin_no2);
      </pre></blockquote>
      <h4>Description</h4>
      <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
      Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
      </p>
      </html>"));
      end cmd_dcmotor_setup;

      function cmd_dcmotor_run "Command to run DC motor after setting up"
        extends Modelica.Icons.Function;
        input Integer handle, motor_no, val;
      
        external cmd_dcmotor_run(handle, motor_no, val) annotation(
          Library = "DCMotor");
        annotation(
          Documentation(info = "<html>
    <h4>Syntax</h4>
    <blockquote><pre>
    Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_run</b>(handle,motor_no,value);
    </pre></blockquote>
    <h4>Description</h4>
    <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
    Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
    </p>
    </html>"));
      end cmd_dcmotor_run;

      function cmd_dcmotor_release "Command to release pins which have setup for DC motor"
        extends Modelica.Icons.Function;
        input Integer handle, motor_no;
      
        external cmd_dcmotor_release(handle, motor_no) annotation(
          Library = "DCMotor");
        annotation(
          Documentation(info = "<html>
    <h4>Syntax</h4>
    <blockquote><pre>
    Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_release</b>(handle,motor_no);
    </pre></blockquote>
    <h4>Description</h4>
    <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
    Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
    </p>
    </html>"));
      end cmd_dcmotor_release;

      function cmd_servo_attach "Command to attach servo motor to Arduino"
        extends Modelica.Icons.Function;
        input Integer handle, servo_no;
      
        external cmd_servo_attach(handle, servo_no) annotation(
          Library = "ServoMotor");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>cmd_servo_attach</b>(handle,servo_no);
  </pre></blockquote>
  <h4>Description</h4>
  <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
  The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
  A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
  </p>
  </html>"));
      end cmd_servo_attach;

      function cmd_servo_move "Command to run servo motor which has been setup"
        extends Modelica.Icons.Function;
        input Integer handle, servo_no, val;
      
        external cmd_servo_move(handle, servo_no, val) annotation(
          Library = "ServoMotor");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>cmd_servo_move</b>(handle,servo_no,value);
  </pre></blockquote>
  <h4>Description</h4>
  <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
  The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
  A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
  </p>
  </html>"));
      end cmd_servo_move;

      function cmd_servo_detach "Command to release the pin which has been setup for servo motor"
        extends Modelica.Icons.Function;
        input Integer handle, servo_no;
      
        external cmd_servo_attach(handle, servo_no) annotation(
          Library = "ServoMotor");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.Functions.<b>cmd_servo_detach</b>(handle,servo_no);
  </pre></blockquote>
  <h4>Description</h4>
  <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
  The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
  A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
  </p>
  </html>"));
      end cmd_servo_detach;

      function ieeesingle2num "ieee-745 floating point converter"
        extends Modelica.Icons.Function;
        input String hexa;
        output Real y;
      
        external y = ieeesingle2num(hexa) annotation(
          Library = "ieeesingle2num");
        annotation(
          Documentation(info = "<html>
<h4>Syntax</h4>
<blockquote><pre>
Arduino.SerialCommunication.Functions.<b>ieeesingle2num</b>(hexa);
</pre></blockquote>
<h4>Description</h4>
<p>Converts an hexadecimal integer to ieee single precision format
    </p>
</html>"));
      end ieeesingle2num;

      function math_floor "Floor function"
        extends Modelica.Icons.Function;
        input Real x;
        output Integer y;
      
        external y = mfloor(x) annotation(
          Library = "floor");
        annotation(
          Documentation(info = "<html>
    <h4>Syntax</h4>
    <blockquote><pre>
    Arduino.SerialCommunication.Functions.<b>math_floor</b>(x);
    </pre></blockquote>
    <h4>Description</h4>
    <p>Returns the greatest integer less than or equal to x
    </p>
    </html>"));
      end math_floor;

      function getArduinoVersion "Returns the Arduino version used"
        extends Modelica.Icons.Function;
        output String arduinoVersion(fixed = true);
      algorithm
        arduinoVersion := "1.1";
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.<b>getArduinoVersion</b>();
  </pre></blockquote>
  <h4>Description</h4>
  <p>Gives the version of the arduino used.
  </p>
  </html>"));
      end getArduinoVersion;

      function cmd_encoder_init "Initiates the encoder"
        extends Modelica.Icons.Function;
        input Integer h, encoder_mode, pin_no1, pin_no2;
      
        external cmd_encoder_init(h, encoder_mode, pin_no1, pin_no2) annotation(
          Library = "Encoder");
        annotation(
          Documentation(info = "<html>
  <h4>Syntax</h4>
  <blockquote><pre>
  Arduino.SerialCommunication.<b>cmd_encoder_init</b>(handle,encoder_mode,pin_no1,pin_no2);
  </pre></blockquote>
  <h4>Description</h4>
  <p>Used to read encoder signal from one or more channels
  </p>
  </html>"));
      end cmd_encoder_init;

      //Incomplete

      package MDD_Servo
        extends Modelica.Icons.Package;

        class Init
          extends ExternalObject;

          function constructor "Return device handle"
            extends .Modelica.Icons.Function;
            import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions;
            import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types;
            import sComm = Arduino.SerialCommunication.Functions;
            import Arduino.SerialCommunication.Functions.MDD_Servo;
            input sComm.Types.Servo_no servo_no;
            output sComm.Functions.MDD_Servo.Init servo;
          
            external "C" servo = MDD_avr_servo_initialize(servo_no) annotation(
              Include = "#include \"/home/manas/OpenModelica/Resources/Include/MDDAVRServo.h\"");
          end constructor;

          function destructor "Destructor"
            extends .Modelica.Icons.Function;
            import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types;
            import sComm = Arduino.SerialCommunication.Functions;
            import Arduino.SerialCommunication.Functions.MDD_Servo;
            input sComm.Types.Servo_no servo_no "Device handle";
          
            external "C" MDD_avr_servo_finalize(servo_no) annotation(
              Include = "#include \"/home/manas/OpenModelica/Resources/Include/MDDAVRServo.h\"");
          end destructor;
        end Init;

        function Move
          extends Modelica.Icons.Function;
          import sComm = Arduino.SerialCommunication.Functions;
          input sComm.Functions.MDD_Servo.Init servo;
          input Integer value;
        
          external "C" MDD_avr_servo_move(servo, value) annotation(
            Include = "#include \"/home/manas/OpenModelica/Resources/Include/MDDAVRServo.h\"");
        end Move;
      end MDD_Servo;
    end Functions;

    package Examples
      extends Modelica.Icons.ExamplesPackage;

      package led
        extends Modelica.Icons.ExamplesPackage;

        model led_blue "Turn on Blue LED"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              digital_out := sComm.cmd_digital_out(1, 27, 1) "This will turn ON the blue LED";
            end if;
            strm.print(String(time));
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end led_blue;


        model led_blue_delay "Turn on Blue LED for a period of 2 seconds"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED";
              sComm.delay(2000) "let the blue LED be on for two seconds";
              digital_out := sComm.cmd_digital_out(1, 9, 0) "turn off blue LED";
              sComm.delay(2000) "let the blue LED be off for two seconds";
            end if;
            strm.print(String(time));
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end led_blue_delay;

        model led_blue_red "Turn on Red & Blue LED"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              sComm.delay(2000);
              digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED";
              digital_out := sComm.cmd_digital_out(1, 11, 1) "This will turn the red LED";
              sComm.delay(5000) "Delay for 5 seconds";
              digital_out := sComm.cmd_digital_out(1, 9, 0) "This turns off the blue Led";
              sComm.delay(3000) "Delay for 3 seconds";
              digital_out := sComm.cmd_digital_out(1, 11, 0) "This turns off the red Led";
            end if;
            strm.print(String(time));
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end led_blue_red;

        model led_blink "This will turn on and turn off the user LED for every second for 10 times"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 57600) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              for i in 1:10 loop
                digital_out := sComm.cmd_digital_out(1, 30, 0) "This will turn off the LED";
                sComm.delay(500) "Delay for 0.5 seconds";
                digital_out := sComm.cmd_digital_out(1, 30, 1) "This turns the Led";
                sComm.delay(500) "Delay for 0.5 seconds";
              end for;
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end led_blink;

        model led_green_blink "This will turn on and turn off the green LED for every second for 5 times"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(1000);
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              for i in 1:10 loop
                digital_out := sComm.cmd_digital_out(1, 10, 0) "This will turn off the green LED";
                sComm.delay(1000) "Delay for 1 second";
                digital_out := sComm.cmd_digital_out(1, 10, 1) "This turns the green Led";
                sComm.delay(1000) "Delay for 1 second";
              end for;
            end if;
            strm.print(String(time));
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end led_green_blink;
      end led;

      package push
        extends Modelica.Icons.ExamplesPackage;

        model led_push_button "Conrolling LED with PushButton"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_in(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            digital_in := sComm.cmd_digital_in(1, 12) "Read from digital pin 12";
            if digital_in == 0 then
              digital_out := sComm.cmd_digital_out(1, 9, 0) "This will turn OFF the blue LED";
              sComm.delay(200);
            else
              digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED";
              sComm.delay(200);
            end if;
          end if;
//for i in 1:1000 loop
//end for;
//strm.print(String(time));
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.01));
        end led_push_button;

        model push_button_status "Checking Status of PushButton"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer digital_in(fixed = false);
          Integer digital_out(start = 0, fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 1, 115200) "At port 0 with baudrate of 115200";
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            digital_in := sComm.cmd_digital_in(1, 12);
            if digital_in == 0 then
              digital_out := sComm.cmd_digital_out(1, 9, 0) "This will turn OFF the blue LED";
              strm.print("LOW");
              sComm.delay(200);
            else
              digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED";
              strm.print("HIGH");
              sComm.delay(200);
            end if;
          end if;
//for i in 1:1000 loop
//end for;
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//sComm.cmd_arduino_meter(digital_in);
          annotation(
            experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.01));
        end push_button_status;
      end push;

      package ldr
        extends Modelica.Icons.ExamplesPackage;

        model ldr_led "LED indicating light sensor readings"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer analog_in(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 2, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)";
            strm.print(String(analog_in));
            if analog_in < 300 then
              digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED";
            else
              digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED";
            end if;
            sComm.delay(200);
          end if;
//for i in 1:500 loop
//end for;
//strm.print(String(time));
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//Run for 500 iterations
//Setting Threshold value of 300
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.02));
        end ldr_led;

        model ldr_read "Reading light intensity using ldr"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer analog_in(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 2, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)";
            strm.print("LDR Readings at time " + String(time) + " : " + String(analog_in));
            sComm.delay(500);
          end if;
//for i in 1:10 loop
//end for;
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//Run for 10 iterations
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 1));
        end ldr_read;
      end ldr;

      package pot
        extends Modelica.Icons.ExamplesPackage;

        model pot_threshold
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer analog_in(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(1000);
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            analog_in := sComm.cmd_analog_in(1, 2) "read analog pin 2";
            strm.print("Potentiometer Readings:" + String(analog_in));
            if analog_in >= 0 and analog_in < 320 then
              digital_out := sComm.cmd_digital_out(1, 11, 1) "Turn ON LED";
              sComm.delay(1000);
              digital_out := sComm.cmd_digital_out(1, 11, 0) "Turn OFF LED";
            elseif analog_in >= 320 and analog_in <= 900 then
              digital_out := sComm.cmd_digital_out(1, 10, 1) "Turn ON LED";
              sComm.delay(1000);
              digital_out := sComm.cmd_digital_out(1, 10, 0) "Turn OFF LED";
            elseif analog_in > 900 and analog_in <= 1023 then
              digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED";
              sComm.delay(1000);
              digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED";
            end if;
          end if;
//for i in 1:10 loop
//end for;
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//Run for 10 iterations
//Threshold 1
//Threshold 2
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.01));
        end pot_threshold;
      end pot;

      package thermistor
        extends Modelica.Icons.ExamplesPackage;

        model therm_buzzer "Sound buzzer depending on thermistor readings"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer analog_in(fixed = false);
          Integer digital_out(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 4";
            if analog_in > 500 then
              digital_out := sComm.cmd_digital_out(1, 3, 1) "Turn ON Buzzer";
            else
              digital_out := sComm.cmd_digital_out(1, 3, 0) "Turn OFF Buzzer";
            end if;
            sComm.delay(200);
          end if;
//for i in 1:500 loop
//end for;
//Run for 500 iterations
//Setting Threshold value of 500
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.02));
        end therm_buzzer;

        model therm_read "Thermistor Readings"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer analog_in(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "At port 0 with baudrate of 115200";
            sComm.delay(2000);
          end when;
          if ok <> 0 then
            strm.print("Unable to open serial port, please check");
          else
            analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 5 (ldr)";
            strm.print("Thermistor Readings " + " : " + String(analog_in));
            sComm.delay(500);
          end if;
//for i in 1:20 loop
//end for;
          when terminal() then
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//Run for 20 iterations
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.5));
        end therm_read;
      end thermistor;

      package dcmotor
        extends Modelica.Icons.ExamplesPackage;

        model dcmotor_clock "Rotate DC Motor clockwise"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Unable to open serial port, please check");
            else
              sComm.delay(2000);
              sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
              sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
              sComm.delay(3000) "This is allowed to continue for 3 seconds";
              sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end dcmotor_clock;

        model dcmotor_both "Rotate DC Motor in both directions"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Unable to open serial port, please check");
            else
              sComm.delay(2000);
              sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
              sComm.cmd_dcmotor_run(1, 1, 255) "Motor 1 runs at PWM 100";
              sComm.delay(3000) "for 3 seconds";
              sComm.cmd_dcmotor_run(1, 1, -255) "Motor 1 runs at PWM -100 in reverse direction";
              sComm.delay(2000) "for 2 seconds";
              sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end dcmotor_both;

        model dcmotor_loop "Rotate DC Motor in both directions in a loop"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Unable to open serial port, please check");
            else
              for i in 1:4 loop
                sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10";
                sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
                sComm.delay(2000) "for 3 seconds";
                sComm.cmd_dcmotor_run(1, 1, 0) "Halt the motor";
                sComm.delay(2000) "for 2 seconds";
                sComm.cmd_dcmotor_run(1, 1, -100) "Run it at PWM 100 in reverse direction";
                sComm.delay(2000) "for 2 seconds";
                sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
              end for;
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
        end dcmotor_loop;
      end dcmotor;

      package servo
        extends Modelica.Icons.ExamplesPackage;

        model servo_init "Rotate Servo Motor by 30 degrees.After the roataion reset it by 0"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              sComm.delay(2000);
              sComm.cmd_servo_attach(1, 1) "To attach the motor to pin 9 of servo1";
              sComm.cmd_servo_move(1, 1, 0) "tell servo to rotate by 30 degrees";
              sComm.delay(3000);
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
          annotation(
            experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
        end servo_init;

        model servo_loop "Rotate servo motor by 20 degrees 10 times"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
          Integer angle(fixed = true);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              sComm.delay(2000);
              sComm.cmd_servo_attach(1, 1) "Attach motor to pin 9. 1 means pin 9.";
              sComm.delay(2000);
              angle := 20 "Angle by which it has to move";
              for i in 1:10 loop
                sComm.cmd_servo_move(1, 1, angle * i) "tell servo to rotate by 20 degrees";
                sComm.delay(1000) "waits for a sec";
              end for;
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//sComm.cmd_servo_detach(1, 1) "Detach the motor";
          annotation(
            experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
        end servo_loop;

        model servo_reverse
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              sComm.delay(2000);
              sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9. 1 means 9";
              sComm.cmd_servo_move(1, 1, 90) "Move the servo to 90 degree";
              sComm.delay(1000) "be there for one second";
              sComm.cmd_servo_move(1, 1, 45) "Move the servo to 45 degree";
              sComm.delay(1000) "be there for one second";
              sComm.delay(1000);
            end if;
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//sComm.cmd_servo_detach(1, 1) "Detach the motor";
          annotation(
            experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
        end servo_reverse;

        model servo_pot "Control Servo Motor using Potentiometer"
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import strm = Modelica.Utilities.Streams;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
          Integer analog_in(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
            if ok <> 0 then
              strm.print("Check the serial port and try again");
            else
              sComm.delay(2000);
              sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9";
              sComm.delay(2000);
              for i in 1:5000 loop
                analog_in := sComm.cmd_analog_in(1, 2) "Read potentiometer value";
                analog_in := sComm.math_floor(analog_in * (180 / 1023)) "Scale Potentiometer value to 0-180";
                sComm.cmd_servo_move(1, 1, analog_in) "Command the servo motor";
                sComm.delay(1000) "sleep for 500 milliseconds";
                strm.print("Potentiometer Reading at time" + String(time) + " : " + String(analog_in));
              end for;
            end if;
            sComm.cmd_servo_detach(1, 1) "Detach the motor";
            sComm.delay(5000);
            c_ok := sComm.close_serial(1) "To close the connection safely";
          end when;
//5,000 itterations
          annotation(
            experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
        end servo_pot;
      end servo;

      package modbus
        extends Modelica.Icons.ExamplesPackage;

        function read_voltage
          extends Modelica.Icons.Function;
        
          external read_voltage() annotation(
            Library = "Modbus");
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.Examples.modbus.<b>read_voltage</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end read_voltage;

        function read_current
          extends Modelica.Icons.Function;
        
          external read_voltage() annotation(
            Library = "Modbus");
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.Examples.modbus.<b>read_current</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end read_current;

        function read_val
          extends Modelica.Icons.Function;
          input Integer addr_byte;
          output Real p;
        
          external p = read_val(addr_byte) annotation(
            Library = "Modbus");
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.Examples.modbus.<b>read_val</b>(address_byte);
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end read_val;

        function read_active_power
          extends Modelica.Icons.Function;
        
          external read_active_power() annotation(
            Library = "Modbus");
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.Examples.modbus.<b>read_active_power</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end read_active_power;

        model modbus_test
          extends Modelica.Icons.Example;
          import sComm = Arduino.SerialCommunication.Functions;
          import modbus = Arduino.SerialCommunication.Examples.modbus;
          Integer ok(fixed = false);
          Integer c_ok(fixed = false);
        algorithm
          when initial() then
            ok := sComm.open_serial(1, 0, 9600);
            modbus.read_voltage();
            modbus.read_current();
            modbus.read_active_power();
            c_ok := sComm.close_serial(1);
          end when;
        end modbus_test;
      end modbus;
    end Examples;

    package MDD_Examples "Interfacing arduino with OpenModelica using Modelica Device Drivers"
      extends Modelica.Icons.ExamplesPackage;

      package MDD_led
        extends Modelica.Icons.ExamplesPackage;

        model MDD_led_blue ""
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-44, 66}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {39, -21}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
            Placement(visible = true, transformation(origin = {-41, -21}, extent = {{-15, -17}, {15, 17}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{-24, -20}, {14, -20}, {14, -20}, {16, -20}}, color = {255, 0, 255}));
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.MDD_Examples.MDD_led.<b>MDD-led_blue</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end MDD_led_blue;

        model MDD_led_blue_delay
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {31, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {41, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 5 then true else false) annotation(
            Placement(visible = true, transformation(origin = {-27, -16}, extent = {{-21, -16}, {21, 16}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{-4, -16}, {20, -16}}, color = {255, 0, 255}));
        end MDD_led_blue_delay;

        model MDD_led_blink
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-45, 71}, extent = {{-23, -23}, {23, 23}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'5', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {42, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {23, 71}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation(
            Placement(visible = true, transformation(origin = {-24, -21}, extent = {{-16, -15}, {16, 15}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{-6, -21}, {16, -21}, {16, -22}, {18, -22}}, color = {255, 0, 255}));
        end MDD_led_blink;

        model MDD_led_blue_red
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-47, 47}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {38, -16}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {40, 44}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {38, -62}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 5 then true else false) annotation(
            Placement(visible = true, transformation(origin = {-32, -16}, extent = {{-18, -14}, {18, 14}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = if time < 8 then true else false) annotation(
            Placement(visible = true, transformation(origin = {-32, -62}, extent = {{-18, -16}, {18, 16}}, rotation = 0)));
        equation
          connect(digitalWriteBoolean2.u, booleanExpression2.y) annotation(
            Line(points = {{18, -62}, {-12, -62}, {-12, -62}, {-12, -62}}, color = {255, 0, 255}));
          connect(booleanExpression2.y, digitalWriteBoolean2.u) annotation(
            Line(points = {{-12, -62}, {18, -62}, {18, -62}, {18, -62}}, color = {255, 0, 255}));
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{-12, -16}, {18, -16}, {18, -16}, {18, -16}}, color = {255, 0, 255}));
        end MDD_led_blue_red;

        model MDD_led_green_blink
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {46, -30}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation(
            Placement(visible = true, transformation(origin = {-17, -30}, extent = {{-15, -14}, {15, 14}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{0, -30}, {24, -30}, {24, -30}, {24, -30}}, color = {255, 0, 255}));
        end MDD_led_green_blink;

        model MDD_traffic_light ""
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega16) annotation(
            Placement(visible = true, transformation(origin = {-44, 42}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1) annotation(
            Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.A) annotation(
            Placement(visible = true, transformation(origin = {39, -21}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
            Placement(visible = true, transformation(origin = {-41, -21}, extent = {{-15, -17}, {15, 17}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{-24, -20}, {14, -20}, {14, -20}, {16, -20}}, color = {255, 0, 255}));
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.MDD_Examples.MDD_led.<b>MDD-led_blue</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>
        </p>
        </html>"));
        end MDD_traffic_light;
      end MDD_led;

      package MDD_push
        extends Modelica.Icons.ExamplesPackage;

        model MDD_led_push_button
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-46, 62}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {-44, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {62, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
            Placement(visible = true, transformation(origin = {8, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
            Placement(visible = true, transformation(origin = {-32, 18}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = false) annotation(
            Placement(visible = true, transformation(origin = {-32, -70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(booleanExpression2.y, logicalSwitch1.u3) annotation(
            Line(points = {{-20, -70}, {-16, -70}, {-16, -36}, {-4, -36}, {-4, -36}}, color = {255, 0, 255}));
          connect(booleanExpression1.y, logicalSwitch1.u1) annotation(
            Line(points = {{-20, 18}, {-14, 18}, {-14, -20}, {-4, -20}, {-4, -20}}, color = {255, 0, 255}));
          connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{20, -28}, {50, -28}, {50, -28}, {50, -28}}, color = {255, 0, 255}));
          connect(digitalReadBoolean1.y, logicalSwitch1.u2) annotation(
            Line(points = {{-32, -28}, {-4, -28}}, color = {255, 0, 255}));
        end MDD_led_push_button;

        model MDD_push_button_status
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-43, 43}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {20, 42}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {-39, -19}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.BooleanValue booleanValue1(use_activePort = true) annotation(
            Placement(visible = true, transformation(origin = {31, -19}, extent = {{-15, -17}, {15, 17}}, rotation = 0)));
        equation
          connect(digitalReadBoolean1.y, booleanValue1.activePort) annotation(
            Line(points = {{-18, -18}, {14, -18}, {14, -18}, {14, -18}}, color = {255, 0, 255}));
        end MDD_push_button_status;

        model pushTest1
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {-60, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {60, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
            Placement(visible = true, transformation(origin = {-2, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1 annotation(
            Placement(visible = true, transformation(origin = {-44, 62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = true) annotation(
            Placement(visible = true, transformation(origin = {-46, -58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{10, -2}, {48, -2}, {48, -2}, {48, -2}}, color = {255, 0, 255}));
          connect(digitalReadBoolean1.y, logicalSwitch1.u2) annotation(
            Line(points = {{-48, -2}, {-14, -2}, {-14, -2}, {-14, -2}}, color = {255, 0, 255}));
          connect(booleanExpression2.y, logicalSwitch1.u3) annotation(
            Line(points = {{-34, -58}, {-24, -58}, {-24, -10}, {-14, -10}, {-14, -10}}, color = {255, 0, 255}));
          connect(booleanExpression1.y, logicalSwitch1.u1) annotation(
            Line(points = {{-32, 62}, {-28, 62}, {-28, 6}, {-14, 6}, {-14, 6}}, color = {255, 0, 255}));
          annotation(
            uses(Modelica_DeviceDrivers(version = "1.5.0"), Modelica(version = "3.2.2")));
        end pushTest1;
      end MDD_push;

      package MDD_ldr
        extends Modelica.Icons.ExamplesPackage;

        model MDD_ldr_led
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-45, 65}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {38, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {79, -23}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
            Placement(visible = true, transformation(origin = {-60, 12}, extent = {{-14, -16}, {14, 16}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression2 annotation(
            Placement(visible = true, transformation(origin = {-59, -79}, extent = {{-13, -17}, {13, 17}}, rotation = 0)));
          Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
            Placement(visible = true, transformation(origin = {28, -22}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
          Modelica.Blocks.Logical.GreaterThreshold greaterThreshold1(threshold = 600) annotation(
            Placement(visible = true, transformation(origin = {-21, -23}, extent = {{-11, -11}, {11, 11}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-72, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
        equation
          connect(adc.y, greaterThreshold1.u) annotation(
            Line(points = {{-50, -22}, {-34, -22}}, color = {0, 0, 127}));
          connect(greaterThreshold1.y, logicalSwitch1.u2) annotation(
            Line(points = {{-8, -22}, {8, -22}, {8, -22}, {8, -22}}, color = {255, 0, 255}));
          connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{46, -22}, {58, -22}, {58, -22}, {58, -22}}, color = {255, 0, 255}));
          connect(booleanExpression1.y, logicalSwitch1.u1) annotation(
            Line(points = {{-44, 12}, {8, 12}, {8, -10}, {8, -10}}, color = {255, 0, 255}));
          connect(booleanExpression2.y, logicalSwitch1.u3) annotation(
            Line(points = {{-44, -78}, {6, -78}, {6, -34}, {8, -34}}, color = {255, 0, 255}));
        end MDD_ldr_led;

        model MDD_ldr_read
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-37, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {50, 38}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-39, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
            Placement(visible = true, transformation(origin = {30, -17}, extent = {{-18, -17}, {18, 17}}, rotation = 0)));
        equation
          connect(adc.y, realValue1.numberPort) annotation(
            Line(points = {{-20, -17}, {7, -17}}, color = {0, 0, 127}));
        end MDD_ldr_read;
      end MDD_ldr;

      package MDD_pot
        extends Modelica.Icons.ExamplesPackage;

        model MDD_pot_threshold ""
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-79, 79}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {80, 80}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica.Blocks.Logical.Switch switch11 annotation(
            Placement(visible = true, transformation(origin = {2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.Switch switch12 annotation(
            Placement(visible = true, transformation(origin = {10, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.Greater greater1 annotation(
            Placement(visible = true, transformation(origin = {42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.Greater greater2 annotation(
            Placement(visible = true, transformation(origin = {36, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {82, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {82, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean3(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
            Placement(visible = true, transformation(origin = {82, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 0) annotation(
            Placement(visible = true, transformation(origin = {-42, 44}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold2(threshold = 320) annotation(
            Placement(visible = true, transformation(origin = {-42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold3(threshold = 900) annotation(
            Placement(visible = true, transformation(origin = {-40, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.RealExpression realExpression1(y = 0) annotation(
            Placement(visible = true, transformation(origin = {-40, -92}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.RealExpression realExpression2(y = 1) annotation(
            Placement(visible = true, transformation(origin = {-44, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.Switch switch1 annotation(
            Placement(visible = true, transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Math.RealToBoolean realToBoolean1(threshold = 0.5) annotation(
            Placement(visible = true, transformation(origin = {44, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-88, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.RealValue realValue1(significantDigits = 5, use_numberPort = true) annotation(
            Placement(visible = true, transformation(origin = {-74, -84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(adc.y, realValue1.numberPort) annotation(
            Line(points = {{-76, 0}, {-74, 0}, {-74, -70}, {-94, -70}, {-94, -84}, {-86, -84}, {-86, -84}}, color = {0, 0, 127}));
          connect(adc.y, greaterEqualThreshold1.u) annotation(
            Line(points = {{-76, 0}, {-70, 0}, {-70, 46}, {-54, 46}}, color = {0, 0, 127}));
          connect(greaterEqualThreshold1.y, switch1.u2) annotation(
            Line(points = {{-31, 46}, {-24, 46}, {-24, 70}, {-12, 70}}, color = {255, 0, 255}));
          connect(adc.y, greaterEqualThreshold3.u) annotation(
            Line(points = {{-76, 0}, {-70, 0}, {-70, -64}, {-52, -64}, {-52, -64}}, color = {0, 0, 127}));
          connect(adc.y, greaterEqualThreshold2.u) annotation(
            Line(points = {{-76, 0}, {-54, 0}, {-54, 0}, {-54, 0}}, color = {0, 0, 127}));
          connect(realToBoolean1.y, digitalWriteBoolean3.u) annotation(
            Line(points = {{56, -64}, {70, -64}, {70, -64}, {70, -64}}, color = {255, 0, 255}));
          connect(switch12.y, realToBoolean1.u) annotation(
            Line(points = {{22, -64}, {32, -64}, {32, -64}, {32, -64}}, color = {0, 0, 127}));
          connect(realExpression1.y, switch1.u3) annotation(
            Line(points = {{-28, -92}, {-16, -92}, {-16, 62}, {-12, 62}, {-12, 62}}, color = {0, 0, 127}));
          connect(realExpression2.y, switch1.u1) annotation(
            Line(points = {{-32, 84}, {-20, 84}, {-20, 78}, {-12, 78}, {-12, 78}}, color = {0, 0, 127}));
          connect(switch1.y, greater2.u1) annotation(
            Line(points = {{12, 70}, {22, 70}, {22, 70}, {24, 70}}, color = {0, 0, 127}));
          connect(greater1.y, digitalWriteBoolean2.u) annotation(
            Line(points = {{54, 0}, {70, 0}}, color = {255, 0, 255}));
          connect(switch11.y, greater2.u2) annotation(
            Line(points = {{14, 0}, {18, 0}, {18, 62}, {24, 62}, {24, 62}}, color = {0, 0, 127}));
          connect(switch11.y, greater1.u1) annotation(
            Line(points = {{14, 0}, {30, 0}}, color = {0, 0, 127}));
          connect(switch12.y, greater1.u2) annotation(
            Line(points = {{22, -64}, {22, -64}, {22, -8}, {30, -8}, {30, -8}}, color = {0, 0, 127}));
          connect(greaterEqualThreshold2.y, switch11.u2) annotation(
            Line(points = {{-30, 0}, {-10, 0}, {-10, 0}, {-10, 0}}, color = {255, 0, 255}));
          connect(greater2.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{48, 70}, {56, 70}, {56, 40}, {70, 40}, {70, 40}}, color = {255, 0, 255}));
          connect(realExpression2.y, switch12.u1) annotation(
            Line(points = {{-32, 84}, {-20, 84}, {-20, -56}, {-2, -56}, {-2, -56}}, color = {0, 0, 127}));
          connect(realExpression2.y, switch11.u1) annotation(
            Line(points = {{-32, 84}, {-20, 84}, {-20, 8}, {-10, 8}, {-10, 8}}, color = {0, 0, 127}));
          connect(realExpression1.y, switch11.u3) annotation(
            Line(points = {{-28, -92}, {-16, -92}, {-16, -8}, {-10, -8}, {-10, -8}}, color = {0, 0, 127}));
          connect(realExpression1.y, switch12.u3) annotation(
            Line(points = {{-28, -92}, {-16, -92}, {-16, -72}, {-2, -72}, {-2, -72}}, color = {0, 0, 127}));
          connect(greaterEqualThreshold3.y, switch12.u2) annotation(
            Line(points = {{-28, -64}, {-2, -64}, {-2, -64}, {-2, -64}}, color = {255, 0, 255}));
          annotation(
            Documentation(info = "<html>
        <h4>Syntax</h4>
        <blockquote><pre>
        Arduino.SerialCommunication.MDD_Examples.MDD_pot.<b>MDD_pot_threshold</b>();
        </pre></blockquote>
        <h4>Description</h4>
        <p>Voltage reference used to represent 10 bit precision(1024) of ADC along with prescaling by by 128.Internal voltage reference is applied to adc.
        </p>
        </html>"));
        end MDD_pot_threshold;
      end MDD_pot;

      package MDD_thermistor
        extends Modelica.Icons.ExamplesPackage;

        model MDD_therm_read
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {40, 42}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-40, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
            Placement(visible = true, transformation(origin = {39, -21}, extent = {{-15, -19}, {15, 19}}, rotation = 0)));
        equation
          connect(adc.y, realValue1.numberPort) annotation(
            Line(points = {{-18, -20}, {20, -20}, {20, -20}, {22, -20}}, color = {0, 0, 127}));
        end MDD_therm_read;

        model MDD_therm_buzzer
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-61, 61}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-68, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {41, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
            Placement(visible = true, transformation(origin = {12, -56}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.D) annotation(
            Placement(visible = true, transformation(origin = {78, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
            Placement(visible = true, transformation(origin = {40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = false) annotation(
            Placement(visible = true, transformation(origin = {10, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = true) annotation(
            Placement(visible = true, transformation(origin = {10, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 550) annotation(
            Placement(visible = true, transformation(origin = {-4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(greaterEqualThreshold1.y, logicalSwitch1.u2) annotation(
            Line(points = {{8, 0}, {28, 0}, {28, 0}, {28, 0}}, color = {255, 0, 255}));
          connect(adc.y, greaterEqualThreshold1.u) annotation(
            Line(points = {{-46, 0}, {-16, 0}, {-16, 0}, {-16, 0}}, color = {0, 0, 127}));
          connect(adc.y, realValue1.numberPort) annotation(
            Line(points = {{-46, 0}, {-32, 0}, {-32, -56}, {0, -56}}, color = {0, 0, 127}));
          connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
            Line(points = {{52, 0}, {66, 0}, {66, 0}, {66, 0}}, color = {255, 0, 255}));
          connect(booleanExpression2.y, logicalSwitch1.u1) annotation(
            Line(points = {{22, 32}, {24, 32}, {24, 8}, {28, 8}, {28, 8}}, color = {255, 0, 255}));
          connect(booleanExpression1.y, logicalSwitch1.u3) annotation(
            Line(points = {{22, -32}, {24, -32}, {24, -8}, {28, -8}, {28, -8}}, color = {255, 0, 255}));
        end MDD_therm_buzzer;
      end MDD_thermistor;

      package MDD_dcmotor
        extends Modelica.Icons.ExamplesPackage;

        model MDD_dcmotor_clock
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation(
            Placement(visible = true, transformation(origin = {51, -3}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 5 then 255 else 0) annotation(
            Placement(visible = true, transformation(origin = {-40, -3}, extent = {{-16, -13}, {16, 13}}, rotation = 0)));
        equation
          connect(pwm.u[1], integerExpression1.y) annotation(
            Line(points = {{28, -3}, {-22, -3}}, color = {255, 127, 0}, thickness = 0.5));
        end MDD_dcmotor_clock;

        model MDD_dcmotor_both
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {56, 60}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {54, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if mod(time, 5) >= 2.5 then 100 else 0) annotation(
            Placement(visible = true, transformation(origin = {-41, 3.55271e-15}, extent = {{-23, -20}, {23, 20}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if mod(time, 5) < 2.5 then 100 else 0) annotation(
            Placement(visible = true, transformation(origin = {-39, -48}, extent = {{-23, -20}, {23, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation(
            Placement(visible = true, transformation(origin = {54, -48}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
        equation
          connect(integerExpression2.y, pwm1.u[1]) annotation(
            Line(points = {{-14, -48}, {28, -48}, {28, -48}, {30, -48}}, color = {255, 127, 0}));
          connect(integerExpression1.y, pwm.u[1]) annotation(
            Line(points = {{-16, 0}, {28, 0}, {28, 0}, {30, 0}}, color = {255, 127, 0}));
        end MDD_dcmotor_both;

        model MDD_dcmotor_loop
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 62}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {44, 16}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation(
            Placement(visible = true, transformation(origin = {44, -30}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if mod(time, 6) < 3 then 255 else 0) annotation(
            Placement(visible = true, transformation(origin = {-53, 16}, extent = {{-17, -16}, {17, 16}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if mod(time, 6) > 3 then 255 else 0) annotation(
            Placement(visible = true, transformation(origin = {-52, -30}, extent = {{-16, -14}, {16, 14}}, rotation = 0)));
        equation
          connect(integerExpression2.y, pwm1.u[1]) annotation(
            Line(points = {{-34, -30}, {24, -30}}, color = {255, 127, 0}));
          connect(integerExpression1.y, pwm.u[1]) annotation(
            Line(points = {{-34, 16}, {24, 16}}, color = {255, 127, 0}));
        end MDD_dcmotor_loop;
      end MDD_dcmotor;

      package MDD_servo
        extends Modelica.Icons.ExamplesPackage;

        model MDD_servo_init
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 58}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {59, 59}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {44, -6}, extent = {{-28, -28}, {28, 28}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 30) annotation(
            Placement(visible = true, transformation(origin = {-57, -6}, extent = {{-23, -18}, {23, 18}}, rotation = 0)));
        equation
          connect(integerExpression1.y, pwm.u[1]) annotation(
            Line(points = {{-32, -6}, {10, -6}}, color = {255, 127, 0}));
        end MDD_servo_init;

        model MDD_servo_loop
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-41, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {80, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.MathInteger.TriggeredAdd triggeredAdd1(use_reset = false, use_set = false) annotation(
            Placement(visible = true, transformation(origin = {10, -8}, extent = {{-6, -6}, {6, 6}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 10) annotation(
            Placement(visible = true, transformation(origin = {-34, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if mod(time, 0.2) > 0.1 then true else false) annotation(
            Placement(visible = true, transformation(origin = {-22, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(booleanExpression1.y, triggeredAdd1.trigger) annotation(
            Line(points = {{-10, -32}, {6, -32}, {6, -16}, {6, -16}}, color = {255, 0, 255}));
          connect(integerExpression1.y, triggeredAdd1.u) annotation(
            Line(points = {{-22, -8}, {2, -8}, {2, -8}, {2, -8}}, color = {255, 127, 0}));
          connect(triggeredAdd1.y, pwm.u[1]) annotation(
            Line(points = {{17, -8}, {68, -8}}, color = {255, 127, 0}));
        end MDD_servo_loop;

        model MDD_servo_pot
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {39, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 180, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
            Placement(visible = true, transformation(origin = {-52, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {48, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Blocks.Math.RealToInteger realToInteger1 annotation(
            Placement(visible = true, transformation(origin = {-6, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(adc.y, realToInteger1.u) annotation(
            Line(points = {{-40, -10}, {-18, -10}, {-18, -10}, {-18, -10}, {-18, -10}}, color = {0, 0, 127}));
          connect(realToInteger1.y, pwm.u[1]) annotation(
            Line(points = {{6, -10}, {36, -10}, {36, -10}, {36, -10}}, color = {255, 127, 0}));
        end MDD_servo_pot;

        model MDD_servo_reverse
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.01, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-59, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {55, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
          Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 0.2 then 22 else 15) annotation(
            Placement(visible = true, transformation(origin = {-44, 0}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
            Placement(visible = true, transformation(origin = {44, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(integerExpression1.y, pwm.u[1]) annotation(
            Line(points = {{-20, 0}, {32, 0}}, color = {255, 127, 0}));
        end MDD_servo_reverse;
      end MDD_servo;

      package MDD_modbus
        extends Modelica.Icons.ExamplesPackage;

        model MDD_read_val
          extends Modelica.Icons.Example;
          inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
            Placement(visible = true, transformation(origin = {-45, 67}, extent = {{-15, -15}, {15, 15}}, rotation = 0)));
          Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
            Placement(visible = true, transformation(origin = {28, 68}, extent = {{-12, -12}, {12, 12}}, rotation = 0)));
          Modelica.Blocks.MathInteger.MultiSwitch multiSwitch1(expr = {86, 88, 78}, nu = 3, use_pre_as_default = true, y_default = 0) annotation(
            Placement(visible = true, transformation(origin = {-32.6577, -10}, extent = {{-10.0019, -22}, {30.0056, 22}}, rotation = 0)));
          Modelica.Blocks.Interaction.Show.RealValue realValue1 annotation(
            Placement(visible = true, transformation(origin = {60, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Blocks.Read_Val read_Val1 annotation(
            Placement(visible = true, transformation(origin = {26, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(read_Val1.y, realValue1.numberPort) annotation(
            Line(points = {{38, -10}, {48, -10}, {48, -10}, {48, -10}}, color = {0, 0, 127}));
          connect(multiSwitch1.y, read_Val1.u) annotation(
            Line(points = {{-2, -10}, {14, -10}, {14, -10}, {14, -10}}, color = {255, 127, 0}));
        end MDD_read_val;
      end MDD_modbus;
    end MDD_Examples;

    package Blocks
      extends Modelica.Icons.Package;

      model Read_Val
        extends Modelica.Blocks.Interfaces.SISO;
        import Modelica_DeviceDrivers.EmbeddedTargets.AVR;
        import sComm = Arduino.SerialCommunication.Functions;
        outer Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu;
        annotation(
          defaultComponentName = "Read_Val",
          Icon(graphics = {Text(extent = {{-95, -95}, {95, 95}}, textString = "Read_Val", fontName = "Arial")}));
      end Read_Val;
    end Blocks;

    package Icons "Collection of icons used for library components"
      extends Modelica.Icons.IconsPackage;

      partial package GenericICPackage "Icon with a generic IC"
        annotation(
          Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}),
          Documentation(info = "<html>
    <p>
    This partial class is intended to design a <em>default icon for microcontrollers</em>.
    </p>
    </html>"));
      end GenericICPackage;

      partial block GenericIC "Icon with a generic IC"
        annotation(
          Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}),
          Documentation(info = "<html>
    <p>
    This partial class is intended to design a <em>default icon for microcontrollers</em>.
    </p>
    </html>"));
      end GenericIC;

      partial package FunctionLayerIcon "Icon for packages that represent the function layer"
        extends Modelica.Icons.Package;
        annotation(
          Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Text(lineColor = {128, 128, 128}, extent = {{-90, -90}, {90, 90}}, textString = "f"), Ellipse(lineColor = {128, 128, 128}, extent = {{-80, -80}, {80, 80}})}),
          Documentation(info = "<html>
    <p>This icon indicates Modelica functions.</p>
    </html>"));
      end FunctionLayerIcon;
      annotation(
        preferredView = "info",
        Documentation(info = "<html>
    <p>
    A collection of basic icons to be used for different elements of the library.
    </p>
    </html>"));
    end Icons;
    annotation(
      Documentation(info = "<html>
<h4>Description</h4>
<p>
A serial communication package for hardware interfacing.
</p>
</html>"));
  end SerialCommunication;
  annotation(
    uses(Modelica_DeviceDrivers(version = "1.5.0"), Modelica(version = "3.2.2")));
end Arduino;