Exemple #1
0
sound_sensor = 1
button = 6
led = 3
ledbar = 4
ir = 8

val = 0

# grovepi.additional_waiting = 0.005
grovepi.pinMode(sound_sensor, "INPUT")
grovepi.pinMode(button, "INPUT")
grovepi.pinMode(light_sensor, "INPUT")
grovepi.pinMode(led, "OUTPUT")
grovepi.dust_sensor_en()
grovepi.setDustSensorInterval(5000)
grovepi.ir_recv_pin(ir)
# grovepi.ledBar_init(ledbar, 0)

data = {
    'sound': 0,
    'light': 0,
    'button': 0,
    'temp': 0,
    'humidity': 0,
    'prox': 0,
    'dust': 0,
    'ir': 3 * [0]
}

while True:
    data['sound'] = grovepi.analogRead(sound_sensor)
copies of the Software, and to permit persons to whom the Software is
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.
'''

# NOTE:
#		Connect the IR sensor to any port. In the code use the pin as port+1. So if you are connecting the sensor to port 7, use "ir_recv_pin(8)"
import time
import grovepi

grovepi.ir_recv_pin(9)
print("Press any button on the remote to see the data")
while True:
    ir_data_back = grovepi.ir_read_signal()
    if ir_data_back[0] == -1:  #IO Error
        pass
    elif ir_data_back[0] == 0:  #Old signal
        pass
    else:
        print(ir_data_back[1:])  #Current signal from IR remote
    time.sleep(.1)
copies of the Software, and to permit persons to whom the Software is
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.
'''

# NOTE: 
#		Connect the IR sensor to any port. In the code use the pin as port+1. So if you are connecting the sensor to port 7, use "ir_recv_pin(8)"
import time
import grovepi

grovepi.ir_recv_pin(9)
print ("Press any button on the remote to see the data")
while True:
	ir_data_back=grovepi.ir_read_signal()
	if ir_data_back[0]==-1:		#IO Error
		pass
	elif ir_data_back[0]==0:	#Old signal
		pass
	else:
		print (ir_data_back[1:])		#Current signal from IR remote
	time.sleep(.1)
Exemple #4
0
sound_sensor = 1
button = 6
led = 3
ledbar = 4
ir = 8

val = 0

# grovepi.additional_waiting = 0.005
grovepi.pinMode(sound_sensor,"INPUT")
grovepi.pinMode(button,"INPUT")
grovepi.pinMode(light_sensor,"INPUT")
grovepi.pinMode(led, "OUTPUT")
grovepi.dust_sensor_en()
grovepi.setDustSensorInterval(5000)
grovepi.ir_recv_pin(ir)
# grovepi.ledBar_init(ledbar, 0)

data = {
    'sound': 0,
    'light': 0,
    'button': 0,
    'temp': 0,
    'humidity': 0,
    'prox': 0,
    'dust': 0,
    'ir': 3 * [0]
}

while True:
    data['sound'] = grovepi.analogRead(sound_sensor)
Exemple #5
0
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.
'''

# NOTE: 
#		Connect the IR sensor to any port. In the code use the pin as port+1. So if you are connecting the sensor to port 7, use "ir_recv_pin(8)"
import time
import grovepi

grovepi.ir_recv_pin(8)
print ("Press any button on the remote to see the data")
while True:
	ir_data_back=grovepi.ir_read_signal()
	if ir_data_back[0]==-1:		#IO Error
		print ("Error")
		pass
	elif ir_data_back[0]==0:	#Old signal
		print ("Old signal")
		pass

	else:
		print (ir_data_back[1:])		#Current signal from IR remote
	time.sleep(.1)
Exemple #6
0
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.
'''

# NOTE:
#               Connect the IR sensor to any port. In the code use the pin as port+1. So if you are connecting the sensor to port 7, use "ir_recv_pin(8)"
import time
import grovepi

#Detector IR
sensor = 7
grovepi.pinMode(sensor, "INPUT")
#______________________________
grovepi.ir_recv_pin(7)
print("Press any button on the remote to see the data")
while True:
    try:
        # Sensor returns LOW and onboard LED lights up when the
        # received infrared light intensity exceeds the calibrated level
        if grovepi.digitalRead(sensor) == 0:
            print("found something")
            ir_data_back = grovepi.ir_read_signal()
            #  if ir_data_back[0]==-1:         #IO Error
            #  	print ("Error")
            #  	pass
            #	elif ir_data_back[0]==0:        #Old signal
            #        	print ("Old signal")
            #        	pass