Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New in ./examples 3 Push Button e 3 LED #114

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions pingo/arduino/examples/3_pushbutton_led/3_pushbutton_led.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
3 Pushbutton 3 led.

The led comes on when you press the button.

Connections example found on ./3_button.png

"""
# -*- coding: utf-8 -*-
import pingo
import sys


try:
print("Loading board...")
board = pingo.detect.get_board()
print("Its ok...")
led_pin1 = board.pins[13]
led_pin1.mode = pingo.OUT
led_pin2 = board.pins[12]
led_pin2.mode = pingo.OUT
led_pin3 = board.pins[11]
led_pin3.mode = pingo.OUT
button_pin1 = board.pins[2]
button_pin1.mode = pingo.IN
button_pin2 = board.pins[3]
button_pin2.mode = pingo.IN
button_pin3 = board.pins[4]
button_pin3.mode = pingo.IN
except Exception as e:
print("Error on get_board: {}".format(e))
sys.exit(1)

while True:
if button_pin1.state == pingo.HIGH:
led_pin1.hi()
else:
led_pin1.lo()
if button_pin2.state == pingo.HIGH:
led_pin2.hi()
else:
led_pin2.lo()
if button_pin3.state == pingo.HIGH:
led_pin3.hi()
else:
led_pin3.lo()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions pingo/arduino/examples/AnalogReadSerial/AnalogReadSerial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Implementation of a Serial Monitor
for reading the value of a potentiometer.

"""
# -*- coding: utf-8 -*-
import pingo
import time

board = pingo.detect.MyBoard()

sensorValue = board.pins['A0']
sensorValue.mode = pingo.IN

while True:
print(sensorValue.value)
time.sleep(0.05)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions pingo/arduino/examples/DigitalReadSerial/DigitalReadSerial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Implementation of a Serial Monitor
for reading the value (LOW or HIGH) of a PushButton.

"""
# -*- coding: utf-8 -*-
import pingo
import time

board = pingo.detect.MyBoard()

buttonState = board.pins[2]
buttonState.mode = pingo.IN

while True:
print(buttonState.state)
time.sleep(0.05)