Ajouté des composants à Fritzing
This commit is contained in:
20
Serial/minimal_serial.lua
Normal file
20
Serial/minimal_serial.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
count=100
|
||||
|
||||
-- when 4 chars is received.
|
||||
uart.on("data", 4,
|
||||
function(data)
|
||||
count = count - 1
|
||||
print("receive from uart:", data)
|
||||
if data=="quit" or count<1 then
|
||||
uart.on("data") -- unregister callback function
|
||||
end
|
||||
end, 0)
|
||||
-- when '\r' is received.
|
||||
uart.on("data", "\r",
|
||||
function(data)
|
||||
count = count - 1
|
||||
print("receive from uart:", data)
|
||||
if data=="quit\r" or count<1 then
|
||||
uart.on("data") -- unregister callback function
|
||||
end
|
||||
end, 0)
|
||||
Reference in New Issue
Block a user