Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions code/BlinkLed.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local pin=0
local TIMER_ID=1
local duration=1000
local count=10;
local state=gpio.LOW
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(TIMER_ID,duration,tmr.ALARM_AUTO,
function()
count--
if state==gpio.LOW then state=gpio.HIGH
else state=gpio.LOW
end
gpio.write(pin,state)
if (count)==0
then tmr.stop()
end
end
)
9 changes: 9 additions & 0 deletions code/factorial.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
io.write("enter a number")
--io.read()
local fact=1
for i=1,5,1
do
fact=fact*i
end
print("factorial is "..fact)

15 changes: 15 additions & 0 deletions code/prime.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local n=34467
local ch=0
if n%2==0 then ch=1
else
for i=3,math.sqrt(n),1
do
if n%i==0 then
ch=1
break;
end
end
end
if ch==1 then print(n.." is not a prime number")
else print(n.." is a prime number")
end