echo '' ;

ESP32 NodeMCU – Basic Interface Examples

 


LED Grow using Button

LED glow using Button Input Method in While loop

gpio.config( { gpio=23, dir=gpio.OUT }, { gpio=0, dir=gpio.IN}) 
while(true)
do
   if (gpio.read(0)==0) then gpio.write(23, 1) 
   else gpio.write(23, 0) 
   end 
end

LED glow using Button Interrupt Method

gpio.config({gpio=23, dir=gpio.OUT})	--GPIO-23 as OUTPUT
gpio.trig(0, gpio.INTR_UP_DOWN,pin_interrupt_1) --GPIO-0 as INPUT
function pin_interrupt_1(level) 
	if (0 == gpio.read(0)) then
		gpio.write(23, 1)
   else
		gpio.write(23, 0)
    end
end

LED Blink using Timer

gpio.config( { gpio=23, dir=gpio.OUT }) 
ArunEworld_timer = tmr.create()
 ArunEworld_timer:register(1000, tmr.ALARM_AUTO, function() 
	if (gpio.read(23)==1) then gpio.write(23, 0)
	elseif (gpio.read(23)==0) then gpio.write(23, 1)
	end
 end)
ArunEworld_timer:start()

 


 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading