Stap 2: Test
Testen van Lua Code
Test 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>
Test ADC Pin
In dit voorbeeld is eventueel gecombineerd met een lichtsensor 220 Ohm.
<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>
Resultaat
<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