
In this article we will complete the our second project Topic : Python code for IoT Ambient Light Zerynth Lamp . in this project we use Zerytnh App to control a NeoPixel LED strip via mobile using the Zerytnh App, that shows a color picker and a menu for the selection of various pre-configured animations.

Follow the following step one by one :
Table of Contents
step 1 : project pre-requirement
Zerynth Elements:
- Zerynth Studio
- Zerynth App
- Zerynth Shield
Other products :
Arduino DUE / ST Nucleo F401RE / ParticlePhoton./ UDOO or Flip&Clip by Mikroelektronika.
step 2 : connectivity for Python code for IoT Ambient Light Zerynth Lamp project
- Just connect the Zerynth Shield and wifi Shield onto your Arduino IDE. If you use Particle Photon just connect it onto the dedicated connectors on the Zerynth Shield.
- And then Connect the NeoPixel LEDs to the related port on the Zerynth Shield.
- finally Put all the boards and the LEDs into the Lamp.
step 3 : Python programming code for Python code for IoT Ambient Light Zerynth Lamp :
# First you need to import needed modules
import streams
from bcm43362 import bcm43362 as wifi_driver
from wireless import wifi
import animation
from toishield import toishield
# After import the above library or module import you need to import the zerynthapp module
from zerynthapp import zerynthapp
streams.serial()
# Below code use for connecting the wifi network
try:
wifi_driver.auto_init()
print("Establishing Link...")
wifi.link("SSID",wifi.WIFI_WPA2,"password")
print("Ok!")
except Exception as e:
print(e)
# save the template.html in the board flash with new_resource
new_resource("template.html")
#### ZerynthApp Setup
# :: Javascript to Python ::
# the following functions will be called when buttons are pressed
def change_color(r, g, b):
animation.setup_color(r, g, b)
def change_animation(n):
animation.setup_anim(n)
def change_speed(n):
animation.setup_anim_speed(n)
# configure the Zerynth app with a name, a descripton and the template url
vp = zerynthapp.ZerynthApp("Zerynth Lamp", "Try me!", "resource://template.html")
# everytime Javascript generates events the corresponding functions are called
vp.on("change_color", change_color)
vp.on("change_animation", change_animation)
vp.on("change_speed", change_speed)
# run the ZerynthApp!
vp.run()
# since vp.run starts a new thread, you can do whatever else you want down here!
# let's control leds
animation.start(D6, 24)
Finally we are finished the coding works, If you have any query regarding this project then visit to arduino official site.
Summary :In this article we saw Python code for IoT Ambient Light Zerynth Lamp. if any problem about this project then please ask me.
BEST OF LUCK!!!