# Netmax switch example with iot port good one :) import time import Netmaxiot # Connect the Netmaxiot Switch to digital port D3 # SIG,NC,VCC,GND switch = 3 # Connect the Netmaxiot Relay to digital port D4 # SIG,NC,VCC,GND relay = 4 Netmaxiot.pinMode(switch,"INPUT") Netmaxiot.pinMode(relay,"OUTPUT") while True: try: if Netmaxiot.digitalRead(switch): Netmaxiot.digitalWrite(relay,1) else: Netmaxiot.digitalWrite(relay,0) time.sleep(.5) except KeyboardInterrupt: Netmaxiot.digitalWrite(relay,0) break except IOError: print ("Error")
import Netmaxiot import time # Netmaxiot.pinMode(2,"INPUT") # Netmaxiot.pinMode(5,"OUTPUT") # Netmaxiot.pinMode(6,"OUTPUT") # Netmaxiot.pinMode(7,"OUTPUT") a = [2, 3, 4, 5, 6, 7] i = 0 for i in range(0, 6): Netmaxiot.pinMode(a[i], "OUTPUT") i = 0 while 1: for i in range(0, 6): print("LED ON ###############################") Netmaxiot.digitalWrite(a[i], 1) time.sleep(0.5) print("LED OFF ##############################") Netmaxiot.digitalWrite(a[i], 0) time.sleep(0.5) # while 1: # a=Netmaxiot.digitalRead(2) # if(a==1): # print "led on............." # Netmaxiot.digitalWrite(5,1) # time.sleep(0.2) # Netmaxiot.digitalWrite(6,1) # time.sleep(0.2) # Netmaxiot.digitalWrite(7,1) # time.sleep(1) # else:
#!/usr/bin/env python import time import Netmaxiot Netmaxiot.pinMode(2, "OUTPUT") Netmaxiot.pinMode(3, "OUTPUT") Netmaxiot.pinMode(4, "OUTPUT") Netmaxiot.pinMode(5, "OUTPUT") Netmaxiot.pinMode(6, "OUTPUT") time.sleep(1) i = 0 try: Netmaxiot.digitalWrite(2, 0) Netmaxiot.digitalWrite(3, 0) Netmaxiot.digitalWrite(4, 0) Netmaxiot.analogWrite(3, 255) time.sleep(2) Netmaxiot.analogWrite(3, 128) time.sleep(2) while True: print(i) Netmaxiot.analogWrite(3, i) Netmaxiot.analogWrite(5, i) Netmaxiot.analogWrite(6, i) i = i + 5 time.sleep(0.05) if i > 255: i = 0 except KeyboardInterrupt: Netmaxiot.analogWrite(3, 0)
# SIG,NC,VCC,GND led = 4 # Turn on LED once sensor exceeds threshold resistance threshold = 10 Netmaxiot.pinMode(light_sensor, "INPUT") Netmaxiot.pinMode(led, "OUTPUT") while True: try: # Get sensor value sensor_value = Netmaxiot.analogRead(light_sensor) # Calculate resistance of sensor in K resistance = (float)(1023 - sensor_value) * 10 / sensor_value if resistance > threshold: # Send HIGH to switch on LED Netmaxiot.digitalWrite(led, 1) else: # Send LOW to switch off LED Netmaxiot.digitalWrite(led, 0) print("sensor_value = %d resistance =%.2f" % (sensor_value, resistance)) time.sleep(.5) except IOError: print("Error")
import Netmaxiot from time import sleep pins = [2, 3, 4, 5, 6, 7] for i in range(0, 6): Netmaxiot.pinMode(pins[i], "OUTPUT") while True: for i in range(0, 6): Netmaxiot.digitalWrite(pins[i], 1) sleep(0.1) print i sleep(2) for i in range(5, -1, -1): Netmaxiot.digitalWrite(pins[i], 0) sleep(0.1) print i sleep(2)
#!/usr/bin/env python import Netmaxiot import time Netmaxiot.pinMode(5,"OUTPUT") Netmaxiot.pinMode(6,"OUTPUT") Netmaxiot.pinMode(7,"OUTPUT") try: while 1: print("led on................................") Netmaxiot.digitalWrite(5,1) time.sleep(0.2) Netmaxiot.digitalWrite(6,1) time.sleep(0.2) Netmaxiot.digitalWrite(7,1) time.sleep(1) print("led off...............................") Netmaxiot.digitalWrite(5,0) time.sleep(0.2) Netmaxiot.digitalWrite(6,0) time.sleep(0.2) Netmaxiot.digitalWrite(7,0) time.sleep(1) except: print("Error !!! Please Check Your Connections")
import Netmaxiot from time import sleep led=3 led1=5 led2=6 Netmaxiot.pinMode(led,"OUTPUT") Netmaxiot.pinMode(led1,"OUTPUT") Netmaxiot.pinMode(led2,"OUTPUT") sleep(1) i=0 try: Netmaxiot.digitalWrite(led,0) Netmaxiot.digitalWrite(led1,0) Netmaxiot.digitalWrite(led2,0) while 1: print(i) print("analog pin 3,5,6,9") Netmaxiot.analogWrite(led,i) Netmaxiot.analogWrite(led1,i) Netmaxiot.analogWrite(led2,i) i=i+5 sleep(0.05) if(i>255): i=0 except KeyboardInterrupt: Netmaxiot.digitalWrite(led,0) Netmaxiot.digitalWrite(led1,0) Netmaxiot.digitalWrite(led2,0)
button = 14 # This is the A0 pin. buzzer = 8 # This is the D8 pin. Netmaxiot.pinMode(button, "INPUT") Netmaxiot.pinMode(buzzer, "OUTPUT") print("Netmaxiot Basic Hardware Test.") print( "Setup: Connect the button sensor to port A0. Connect a simple Buzzer to port D8." ) print( "Press the button on Netmax iot Shield and the buzzer will buzz tadaaaaaa!" ) time.sleep(4.0) while True: try: butt_val = Netmaxiot.digitalRead( button) # Each time we go through the loop, we read A0. print(butt_val) # Print the value of A0 huhaaaaa hahaha :) if butt_val == 1: Netmaxiot.digitalWrite(buzzer, 1) print('start') time.sleep(1) else: Netmaxiot.digitalWrite(buzzer, 0) time.sleep(.5) except IOError: print("Error")