# 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")
#!/usr/bin/env python import time import Netmaxiot button2 = 2 button3 = 3 button4 = 4 sensor0 = 0 sensor1 = 1 sensor2 = 2 Netmaxiot.pinMode(button2, "INPUT") Netmaxiot.pinMode(button3, "INPUT") Netmaxiot.pinMode(button4, "INPUT") while True: try: print time.time(), d2 = Netmaxiot.digitalRead(button2) d3 = Netmaxiot.digitalRead(button3) d4 = Netmaxiot.digitalRead(button4) sensor_value0 = Netmaxiot.analogRead(sensor0) sensor_value1 = Netmaxiot.analogRead(sensor1) sensor_value2 = Netmaxiot.analogRead(sensor2) print("%d,%d,%d" % (d2, d3, d4)), print("%d,%d,%d" % (sensor_value0, sensor_value1, sensor_value2)) except IOError: print("Error")
# :) # retriggerable means the sensor will continue outputting high if motion was detected before the hold timer expires. # non-retriggerable means the sensor will output high for the specified hold time only, then output low until motion is detected again. # if there is constant motion detected, retriggerable will stay high for the duration and non-retriggerable will oscillate between high/low. import time import Netmaxiot # Connect the Netmaxiot PIR Motion Sensor to digital pin 8 # NOTE: Some PIR sensors come with the SIG line connected to the yellow wire and some with the SIG line connected to the white wire. # If the example does not work on the first run, try changing the pin number # For example, for port D8, if pin 8 does not work below, change it to pin 7, since each port has 2 digital pins. # For port 4, this would pin 3 and 4 pir_sensor = 8 motion = 0 Netmaxiot.pinMode(pir_sensor, "INPUT") while True: try: # Sense motion, usually human, within the target range motion = Netmaxiot.digitalRead(pir_sensor) if motion == 0 or motion == 1: # check if reads were 0 or 1 it can be 255 also because of IO Errors so remove those values if motion == 1: print('Motion Detected') else: print('-') # if your hold time is less than this, you might not see as many detections time.sleep(.2) except IOError: print("Error")
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")
import Netmaxiot from time import sleep button = 5 button1 = 6 led = 2 led1 = 3 led2 = 4 Netmaxiot.pinMode(button, "INPUT") Netmaxiot.pinMode(button1, "INPUT") Netmaxiot.pinMode(led, "OUTPUT") Netmaxiot.pinMode(led1, "OUTPUT") Netmaxiot.pinMode(led2, "OUTPUT") while 1: if Netmaxiot.digitalRead(button) == 0: Netmaxiot.digitalWrite(led, 1) Netmaxiot.digitalWrite(led1, 1) Netmaxiot.digitalWrite(led2, 1) sleep(0.1) print "1 on" Netmaxiot.digitalWrite(led, 0) Netmaxiot.digitalWrite(led1, 0) Netmaxiot.digitalWrite(led2, 0) sleep(0.1) elif Netmaxiot.digitalRead(button1) == 0: Netmaxiot.digitalWrite(led, 1) Netmaxiot.digitalWrite(led1, 0) Netmaxiot.digitalWrite(led2, 1)
import time import Netmaxiot x = 5 Netmaxiot.pinMode(x, "INPUT") try: while True: lx = Netmaxiot.digitalRead(x) print "the value of our input is=%d" % lx time.sleep(0.2) except IOError: print("Error")
from time import sleep import Netmaxiot s1 = 5 s2 = 6 Netmaxiot.pinMode(s1, "INPUT") Netmaxiot.pinMode(s2, "INPUT") Netmaxiot.pinMode(2, "OUTPUT") Netmaxiot.pinMode(3, "OUTPUT") Netmaxiot.pinMode(4, "OUTPUT") try: while True: x = Netmaxiot.digitalRead(s1) y = Netmaxiot.digitalRead(s2) if x == 0: Netmaxiot.digitalWrite(2, 1) Netmaxiot.digitalWrite(3, 1) Netmaxiot.digitalWrite(4, 1) sleep(0.2) Netmaxiot.digitalWrite(2, 0) Netmaxiot.digitalWrite(3, 0) Netmaxiot.digitalWrite(4, 0) print "Switch 1 pressed" sleep(0.2) elif y == 0: Netmaxiot.digitalWrite(2, 1) Netmaxiot.digitalWrite(3, 1) Netmaxiot.digitalWrite(4, 0) sleep(0.2) Netmaxiot.digitalWrite(2, 0) Netmaxiot.digitalWrite(3, 1) Netmaxiot.digitalWrite(4, 1)
#!/usr/bin/env python # import time import Netmaxiot # Connect the Netmaxiot Switch to digital port D3 # SIG,NC,VCC,GND switch = 3 Netmaxiot.pinMode(switch,"INPUT") while True: try: print(Netmaxiot.digitalRead(switch)) time.sleep(.5) except IOError: print ("Error")
#!/usr/bin/env python # ____________________________________________________ # :) My Button Netmaxiot interfacing # Button Example By NetmaxIOT & Rohitkhosla # OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla # :) #------------------------------------------------------------ import time import Netmaxiot # Connect the Netmaxiot Button to digital port D3 # SIG,NC,VCC,GND button = 3 Netmaxiot.pinMode(button,"INPUT") while True: try: print(Netmaxiot.digitalRead(button)) time.sleep(0.2) except IOError: print ("Error")
#!/usr/bin/env python import time import Netmaxiot # Connect the Netmaxiot Line Finder to digital port D7 # SIG,NC,VCC,GND line_finder = 7 Netmaxiot.pinMode(line_finder, "INPUT") while True: try: # Return HIGH when black line is detected, and LOW when white line is detected if Netmaxiot.digitalRead(line_finder) == 1: print("black line detected") else: print("white line detected") time.sleep(.5) except IOError: print("Error")