Ejemplo n.º 1
0
				print msg
				print "temp: ",temp
		
		elif msg[:8].lower()=="humidity".lower():
			if en_jetduino:
				port=int(msg[8:])
				[temp,humidity] = jetduino.dht(port,0)
				s.sensorupdate({'humidity':humidity})
			if en_debug:
				print msg
				print "humidity:",humidity
		
		elif msg[:8].lower()=="distance".lower():
			if en_jetduino:
				port=int(msg[8:])
				dist=jetduino.ultrasonicRead(port)
				s.sensorupdate({'distance':dist})
			if en_debug:
				print msg
				print "distance=",dist	
		
		elif msg[:3].lower()=="lcd".lower():
			if en_jetduino:
				if en_debug:
					print msg[:3], msg[3:6],msg[6:]
				import grove_rgb_lcd 
				if msg[3:6].lower() == "col".lower():
					rgb = []
					for i in range(0,6,2): 
						rgb.append(int(msg[6:][i:i+2],16))  # convert from one hex string to three ints
					if en_debug:
Ejemplo n.º 2
0
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import jetduino
from jetduino_pins import *

# Connect the Grove Ultrasonic Ranger to digital port D2
# SIG,NC,VCC,GND
ultrasonic_ranger = ARD_D2

while True:
    try:
        # Read distance value from Ultrasonic
        print (jetduino.ultrasonicRead(ultrasonic_ranger))

    except TypeError:
        print ("Error")
    except IOError:
        print ("Error")