I'm trying to do a pretty basic 'get an LED' to blink tutorial with a Raspberry Pi Zero. Following this guide:
Blink: Making An LED Blink On A Raspberry Pi
I'm able to get the LED to turn on and off with the gpio command line utility, and the sample code for using RPi.GPIO works fine as well, but I can not get the GPIO Zero example to work.
from gpiozero import LED
from time import sleep
redLED = LED(21)
print "Press CTRL-C to exit."
try:
while True:
redLED.on()
sleep(0.5)
redLED.off()
sleep(0.5)
finally:
redLED.close()
print "\nCompleted cleanup of GPIO resources."
The code executes with no errors, but the LED doesn't blink. What things can I try to troubleshoot likely problems?
Since the command line and the RPi.GPIO examples work, I'm sure the LED and resistor are wired up correctly, so I'm not sure what to try next.
Related
In Dymola, if an error occurs during the simulation, the calculation would be jammed. How could I stop the simulation now? I tried a lot of methods, but the only way that works right now is using the task manager to terminate the Dymola process.
There are multiple ways to stop a stuck simulation in Dymola
The "Stop" button next to the "Simulation" button. The short-cut for this is F12
Create a empty file "stop" (with no extension) in Dymola's working directory.
Within the (Windows) command-window, hitting CTRL-C a different number of times
once: will give you a status of the progress of the integration
twice: will pause the simulation and will give you some online debugging possibilities
three times: stops the simulation (this will sometimes give you more of the result in the plots than using (1.)
Also you will find the sections "Diagnostics for stuck simulation" and "Debug facilities when running a simulation", which corresponds to (3.), in the Dymola Manual (I think it was Volume 2).
I am working on to enable Wandboard Quad(IMX6Q) Uart 2 features for to get data from GPIO3_26 and GPIO3_27 I enabled Uart2 from dts and recompiled imx6q-wandboard.dtb file ,it seems its working but
when I send the "hello" to ttymxc1 I m seeing the senseless charachters , even if I adjust same baudrate ttymxc1 and my machıne ttyUSB0 (I m using usb to rs232 converter ). I think I need to close some features but I dont know what is it or I need to make some configuration pinmuxing and ALT modes .
Is there any way to change the ALT modes of the features or when we choose the UART or another features it is enabling the dependent ALT Mode ?
Can you give me a suggestion or what Am I doing wrong ?
Must_ba
I'm very very new to programming/coding.
And I have a very specific question, which I didn't find any answers to.
This command below executes perfectly fine if the command is valid.
If I enter an invalid command, an error occurs and the cmd exits.
enter image description here
But how do I make it, if an error happens, the program starts from the beginning rather than the cmd window closes?
So, in short, I want "SIGNAL start" to happen if an error occurs.
I hope you understand, thank you very much.
other:
SAY "Enter your own command:"
PULL command
command
IF command=ERROR THEN DO
SIGNAL start
It would be helpful if you published all of your code but it seems that what you really need to do is code a loop.
/* REXX */
do forever
say "Enter a command"
pull command
"where" word(command,1)
if rc <> 0 then iterate
command
end
I'm running some data analysis in ipython notebook. A separate machine collects some data and saves them to a server folder, and my notebook scans this server periodically for new files, and analyzes them.
I do this in a while loop that checks every second for new files. Currently I have set it up to terminate when some number of new files are analyzed. However, I want to instead terminate upon a keypress.
I have tried try-catching a keyboard interrupt, as suggested here: How to kill a while loop with a keystroke?
but it doesn't seem to work with ipython notebook (I am using Windows).
Using openCV's keywait does work for me, but I was wondering if there are alternative methods without having to import opencv.
I have also tried implementing a button widget that interrupts the loop, as such:
from ipywidgets import widgets
import time
%pylab inline
button = widgets.Button(description='Press to stop')
display(button)
class Mode():
def __init__(self):
self.value='running'
mode=Mode()
def on_button_clicked(b):
mode.value='stopped'
button.on_click(on_button_clicked)
while True:
time.sleep(1)
if mode.value=='stopped':
break
But I see that the loop basically ignores the button presses.
You can trigger a KeyboardInterrupt in a Notebook via the menu "Kernel --> Interrupt".
So use this:
try:
while True:
do_something()
except KeyboardInterrupt:
pass
as suggested here and click this menu entry.
Im trying to send two different g-code instructions to the SKR V1.3 simultaneously using the pi 4B's UART pins to control two wheel stepper motors and one stepper motor for my lidar system:
First i send this command in order to allow un-restricted movement of the motors:
stty -echo && echo "G91" >> /dev/ttyAMA0
But then, When I want to send these commands simultaneously
For wheels,
echo "G1 X80 Y80" >> /dev/ttyAMA0
and for Lidar back n' fourth motion,
echo "G1 Z20" >> /dev/ttyAMA0
wait(3 seconds in python)
echo "G1 Z-20' >> /dev/ttyAMA0
they don't end up being processed at the same time. They work fine when executed alone, but when I execute them at the same time, or one after another, its only when the previous G-code command stops does the next one start. Is there a way to get around this and execute g-code commands simultaneously?
You can add the initial Z command to your existing command:
echo "G1 X80 Y80 Z20" >> /dev/ttyAMA0
I would recommend getting in to pyserial
https://github.com/pyserial/pyserial