New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blink example causes panic #245

Closed
emsi opened this Issue Feb 24, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@emsi

emsi commented Feb 24, 2015

When I tried the blink examle the firmware got PANIC:

NodeMCU 0.9.5 build 20150213  powered by Lua 5.1.4

> lighton=0  tmr.alarm(1,1000,1,function()    if lighton==0 then       lighton=1       led(512,512,512)     else       lighton=0       led(0,0,0)     end   end)
> PANIC: unprotected error in call to Lua API (stdin:1: attempt to call global 'led' (a nil value))

@emsi emsi changed the title from Bling example causes panic to Blink example causes panic Feb 24, 2015

@GeorgeHahn

This comment has been minimized.

Show comment
Hide comment
@GeorgeHahn

GeorgeHahn Feb 27, 2015

Contributor

It looks like you didn't define the led function as shown here.

Contributor

GeorgeHahn commented Feb 27, 2015

It looks like you didn't define the led function as shown here.

@nodemcu

This comment has been minimized.

Show comment
Hide comment
@nodemcu

nodemcu Mar 3, 2015

Owner

yes,
you have to define your led function.

Owner

nodemcu commented Mar 3, 2015

yes,
you have to define your led function.

@nodemcu nodemcu closed this Mar 3, 2015

@skyrocknroll

This comment has been minimized.

Show comment
Hide comment
@skyrocknroll

skyrocknroll Jul 2, 2016

Working Example

-- Blink using timer alarm --
timerId = 0
dly = 1000
-- use D4
ledPin = 4
-- set mode to output
gpio.mode(ledPin,gpio.OUTPUT)
ledState = 0
-- timer loop
tmr.alarm( timerId, dly, 1, function()
  ledState = 1 - ledState;
  -- write state to D4
  gpio.write(ledPin, ledState)
end) 

Source

skyrocknroll commented Jul 2, 2016

Working Example

-- Blink using timer alarm --
timerId = 0
dly = 1000
-- use D4
ledPin = 4
-- set mode to output
gpio.mode(ledPin,gpio.OUTPUT)
ledState = 0
-- timer loop
tmr.alarm( timerId, dly, 1, function()
  ledState = 1 - ledState;
  -- write state to D4
  gpio.write(ledPin, ledState)
end) 

Source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment