Paso 2: prueba
Código de prueba de Lua
Prueba de GPIO, 0, 2, 4, 15
<p>for i=0, 6, 1 do <br> gpio.mode(i, gpio.OUTPUT) end</p><p>for i = 0, 6, 1 do print(i) gpio.write(i, gpio.HIGH) print("HIGH") tmr.delay(1000000); gpio.write(i, gpio.LOW) print("LOW") tmr.delay(1000000); end</p>
Pin de prueba ADC
Este ejemplo es conectar un sensor de luz con 220 ohmios.
<p>-- in you init.lua:<br>if adc.force_init_mode(adc.INIT_VDD33) then node.restart() return -- don't bother continuing, the restart is scheduled end</p><p>for i=0,10 do print("System voltage (mV):", adc.readvdd33(0)) tmr.delay(1000000) end</p>
Resultado
<p>System voltage (mV): 635<br>System voltage (mV): 685 System voltage (mV): 637 System voltage (mV): 574 System voltage (mV): 0 System voltage (mV): 0 System voltage (mV): 209 System voltage (mV): 213 System voltage (mV): 616 System voltage (mV): 672 System voltage (mV): 673</p> Now you can do anything analog read by esp01