Push button to run motors?
See original GitHub issue- ev3dev version: PASTE THE OUTPUT OF
uname -r
HERE - ev3dev-lang-python version: INSERT ALL VERSIONS GIVEN BY
dpkg-query -l python3-ev3dev*
HERE
when I run this program it doesnt quite do what I want. I mostly just want it to run the motor when I push the touch sensor. This is the program I’m running.
#!/usr/bin/env python3
from ev3dev.brickpi3 import *
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor
from ev3dev2.led import Leds
ts = TouchSensor(INPUT_1)
m = LargeMotor(OUTPUT_B)
while True:
if ts.value() == 0:
m.stop(stop_action="brake")
else:
m.run_forever(speed_sp=180) # equivalent to power=20 in EV3-G
When I run the program it just turns the motor but when I unplug the touch sensor the motor stops. I guess I still haven’t been able to find a way to simply touch the touch sensor and have it turn the motor.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
BVPOW Motor Start Stop Push Button Motor On Off Switch ...
BVPOW Motor Start Stop Push Button Motor On Off Switch with Surface Waterproof Dustproof Box Mount KAO-5H 10A AC 220/380V ; Qty:1 ;...
Read more >Switches and Pushbuttons – Basic Motor Control
Pushbuttons are momentary contacts that come available as either normally open (NO) or normally closed (NC) contacts , although many pushbuttons come with...
Read more >Servo Motor + Push Button + Arduino : 5 Steps - Instructables
1. Arduino or any Arduino-compatible microcontroller
Servo motor
Push button switch
10k Ohm Resistor - brown-black-orange 2. 1a
The Black wire connects pin 1 of the switch...
Read more >Motor control with Push button - Tinkercad
Motor control with Push button ... Design is visible in our gallery and to anyone with the link. This is a remix of...
Read more >All About Push Button Starts - Car and Driver
A push button start key fob is a button that allows drivers to start their engine by pressing it. That said, you won't...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems like it would run as long as you are holding down the touch sensor. Add a “break” after the run_forever() call so that you drop out of that while True loop.
try this code, and find the differences: