summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSudhakarKuma2021-05-03 05:13:38 +0530
committerSudhakarKuma2021-05-03 05:13:38 +0530
commit86669d6f44b7fbc4eb65b7f1eb911f02cafee1cc (patch)
tree1c00e80fa674c57853c2ba71ae62c5cee65a79df
parente794d9c61ad1820f2174987fe578b4963fa149c0 (diff)
downloadFLOSS-Arduino-Book-86669d6f44b7fbc4eb65b7f1eb911f02cafee1cc.tar.gz
FLOSS-Arduino-Book-86669d6f44b7fbc4eb65b7f1eb911f02cafee1cc.tar.bz2
FLOSS-Arduino-Book-86669d6f44b7fbc4eb65b7f1eb911f02cafee1cc.zip
Maintain consistency in LED codes
-rw-r--r--user-code/led/OpenModelica/led-blue-delay.mo7
-rw-r--r--user-code/led/OpenModelica/led-blue-red.mo9
-rw-r--r--user-code/led/OpenModelica/led-blue.mo7
-rw-r--r--user-code/led/OpenModelica/led-green-blink.mo15
-rw-r--r--user-code/led/julia/led-blue-red.jl12
-rw-r--r--user-code/led/python/led-green-blink.py4
-rw-r--r--user-code/led/scilab/led-blue-delay.zcosbin4034 -> 4096 bytes
-rw-r--r--user-code/led/scilab/led-blue-red.zcosbin4645 -> 4666 bytes
-rw-r--r--user-code/led/scilab/led-blue.zcosbin3648 -> 3683 bytes
-rw-r--r--user-code/led/scilab/led-green-blink.zcosbin4904 -> 4912 bytes
10 files changed, 29 insertions, 25 deletions
diff --git a/user-code/led/OpenModelica/led-blue-delay.mo b/user-code/led/OpenModelica/led-blue-delay.mo
index d72bec7..d1e9348 100644
--- a/user-code/led/OpenModelica/led-blue-delay.mo
+++ b/user-code/led/OpenModelica/led-blue-delay.mo
@@ -7,7 +7,7 @@ model led_blue_delay "Turn on Blue LED for a period of 2 seconds"
Integer c_ok(fixed = false);
algorithm
when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 0 with baudrate of 115200";
+ ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
sComm.delay(2000);
if ok <> 0 then
strm.print("Check the serial port and try again");
@@ -16,8 +16,9 @@ algorithm
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";
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));
+//strm.print(String(time));
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
end led_blue_delay;
diff --git a/user-code/led/OpenModelica/led-blue-red.mo b/user-code/led/OpenModelica/led-blue-red.mo
index 1962af1..73e24f0 100644
--- a/user-code/led/OpenModelica/led-blue-red.mo
+++ b/user-code/led/OpenModelica/led-blue-red.mo
@@ -7,11 +7,11 @@ model led_blue_red "Turn on Red & Blue LED"
Integer c_ok(fixed = false);
algorithm
when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 0 with baudrate of 115200";
+ ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
+ sComm.delay(2000);
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";
@@ -19,8 +19,9 @@ algorithm
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));
+//strm.print(String(time));
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
end led_blue_red;
diff --git a/user-code/led/OpenModelica/led-blue.mo b/user-code/led/OpenModelica/led-blue.mo
index 5a904ed..f4231c8 100644
--- a/user-code/led/OpenModelica/led-blue.mo
+++ b/user-code/led/OpenModelica/led-blue.mo
@@ -8,14 +8,15 @@ model led_blue "Turn on Blue LED"
algorithm
when initial() then
ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
if ok <> 0 then
strm.print("Check the serial port and try again");
else
+ sComm.delay(1000);
digital_out := sComm.cmd_digital_out(1, 9, 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));
+//strm.print(String(time));
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
end led_blue;
diff --git a/user-code/led/OpenModelica/led-green-blink.mo b/user-code/led/OpenModelica/led-green-blink.mo
index 0ad7257..dae071f 100644
--- a/user-code/led/OpenModelica/led-green-blink.mo
+++ b/user-code/led/OpenModelica/led-green-blink.mo
@@ -7,20 +7,21 @@ model led_green_blink "This will turn on and turn off the green LED for every se
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(1000);
+ ok := sComm.open_serial(1, 2, 115200) "At port 2 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, 10, 0) "This will turn off the green LED";
+ for i in 1:5 loop
+ digital_out := sComm.cmd_digital_out(1, 10, 1) "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";
+ digital_out := sComm.cmd_digital_out(1, 10, 0) "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));
+// strm.print(String(time));
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
end led_green_blink;
diff --git a/user-code/led/julia/led-blue-red.jl b/user-code/led/julia/led-blue-red.jl
index 9d40a1c..58e8341 100644
--- a/user-code/led/julia/led-blue-red.jl
+++ b/user-code/led/julia/led-blue-red.jl
@@ -2,12 +2,12 @@ using SerialPorts
include("ArduinoTools.jl")
ser = ArduinoTools.connectBoard(115200)
-ArduinoTools.pinMode(ser,9,"OUTPUT")
-ArduinoTools.pinMode(ser,11,"OUTPUT")
-ArduinoTools.digiWrite(ser,9,1)
-ArduinoTools.digiWrite(ser,11,1)
+ArduinoTools.pinMode(ser, 9, "OUTPUT")
+ArduinoTools.pinMode(ser, 11, "OUTPUT")
+ArduinoTools.digiWrite(ser, 9, 1)
+ArduinoTools.digiWrite(ser, 11, 1)
sleep(5)
-ArduinoTools.digiWrite(ser,9,0)
+ArduinoTools.digiWrite(ser, 9, 0)
sleep(3)
-ArduinoTools.digiWrite(ser,11,0)
+ArduinoTools.digiWrite(ser, 11, 0)
close(ser)
diff --git a/user-code/led/python/led-green-blink.py b/user-code/led/python/led-green-blink.py
index 320bc1d..cdfc481 100644
--- a/user-code/led/python/led-green-blink.py
+++ b/user-code/led/python/led-green-blink.py
@@ -26,9 +26,9 @@ class LED_ON_OFF_LOOP:
self.red = 11
for i in range(5):
self.obj_arduino.cmd_digital_out(1, self.green, 1)
- sleep(2)
+ sleep(1)
self.obj_arduino.cmd_digital_out(1, self.green, 0)
- sleep(2)
+ sleep(1)
def exit(self):
self.obj_arduino.close_serial()
diff --git a/user-code/led/scilab/led-blue-delay.zcos b/user-code/led/scilab/led-blue-delay.zcos
index ee7f0ac..d8b8bc8 100644
--- a/user-code/led/scilab/led-blue-delay.zcos
+++ b/user-code/led/scilab/led-blue-delay.zcos
Binary files differ
diff --git a/user-code/led/scilab/led-blue-red.zcos b/user-code/led/scilab/led-blue-red.zcos
index 5bf0f41..0b87e6b 100644
--- a/user-code/led/scilab/led-blue-red.zcos
+++ b/user-code/led/scilab/led-blue-red.zcos
Binary files differ
diff --git a/user-code/led/scilab/led-blue.zcos b/user-code/led/scilab/led-blue.zcos
index 8bd1934..1f7bba7 100644
--- a/user-code/led/scilab/led-blue.zcos
+++ b/user-code/led/scilab/led-blue.zcos
Binary files differ
diff --git a/user-code/led/scilab/led-green-blink.zcos b/user-code/led/scilab/led-green-blink.zcos
index c0ce318..e469b48 100644
--- a/user-code/led/scilab/led-green-blink.zcos
+++ b/user-code/led/scilab/led-green-blink.zcos
Binary files differ