Comments (4)
Hey @ADScomics , when you say "terminate a program" do you mean the command that the plugin provides or you terminate it in the Python code?
from lego-spikeprime-mindstorms-vscode.
Hi @PeterStaev, It's when I terminate it with the plugin command via the button next to 'play'. Even just pressing the home button to exit the program does not seem to work for me either. Here's my code if it helps at all. The program itself seems to run properly (Although I'm not sure where it's accessing the code libraries on the top).
# LEGO type:standard slot:1 autostart
from mindstorms import MSHub, Motor, MotorPair, ColorSensor, DistanceSensor, App
from mindstorms.control import wait_for_seconds, wait_until, Timer
from mindstorms.operator import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to, equal_to, not_equal_to
import math
# Create your objects here.
hub = MSHub()
eyes = DistanceSensor('A')
foldingMechanism = MotorPair('C', 'D')
steeringMechanism = Motor('B')
rearWheels = Motor('E')
speed = 0
def BackUp():
global speed
speed = 0
speed = 30
if (dist > 60):
speed = 0
# Write your program here.
#hub.light_matrix.write('Initialized!')
hub.light_matrix.write('Hi!')
hub.light_matrix.write('Hey!')
hub.speaker.start_sound('Hi',100)
while True:
dist = eyes.get_distance_cm()
rearWheels.start(speed)
if hub.right_button.is_pressed():
speed = -100
if hub.left_button.is_pressed():
speed = 0
#if dist != None and dist < 30:
# BackUp()
from lego-spikeprime-mindstorms-vscode.
From what I see from your code you have an endless loop on the main thread. This is what stalls the hub and that's why the central button does not end the program. If you try the same code in the Mindstorms/SPIKE app probably the result will be the same 😃
from lego-spikeprime-mindstorms-vscode.
Gah, that was it! Strangely enough, the Mindstorms app didn't have that same issue, although uploading and running the code was finicky a lot, so maybe that had something to do with it. Thanks for your help! I come from object oriented programming in C sharp, so Python is very new to me. 😅
from lego-spikeprime-mindstorms-vscode.
Related Issues (20)
- How to make the program exit after it's finished HOT 4
- Importing self made modules. HOT 2
- How to download to the brick? HOT 3
- Can't Upload program when unplug USB cable and Plugged again HOT 4
- automatic saving in slot HOT 2
- List more advanced features :-) HOT 1
- Bluetooth not showing up on windows 10 HOT 4
- Cannot find imports. HOT 5
- FLL Coach here (not an actual "issue") HOT 1
- Is it works? HOT 2
- MemoryError when uploading and starting files multiple times HOT 5
- Support for HubOS 3 HOT 14
- question about usage HOT 2
- Enhance COM ports lists HOT 6
- Reconnection over BT fails after disconnect from VScode extension for some time
- spike prime new os connect HOT 1
- Trouble uploading code via VSC HOT 6
- Extension creates *.assembled.py file HOT 1
- Connection to Spike Prime HUB fails over USB without error message HOT 22
- Inlcude a screen shot of the run buttons
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lego-spikeprime-mindstorms-vscode.