Single digit clock on Raspberry Pi in Python [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Brand new here, first question! I was a programer in college, some 15 years ago or so, I picked up a raspberry pi to do some tinkering with and one idea was to try to make a clock like my father made the HARD way back in the 70's, a clock that flashes the time one digit at a time. I have my pi all wired up to an IO chip and that connected to a 7-segment display. I have the display fully working. I used some stock code for the IC chip "MCP23017" and was able to build onto that code by pretty much trial and error and EXCEPTIONALLY rusty programing skills. Never used Python before, but so far hasn't been too hard to figure out.
But now I'm stuck and not sure where to even begin next. I can pull the time into my program and print it to the screen as a complete unit. And I created little functions to display all digits 0-9 but I am at a loss how to take that time and split it into single digits and send those codes. Only way I have been thinking requires many pages of if/elif lines, and that seems very wasteful and dumb, I know it should be easier to be done in under a page of code but I'm at a loss where to begin.
(Python programing in Raspberry Pi) # In case I missed mentioning that
Thanks!
Kevin

Here's an example of using an MCP23017 with the raspberry pi
Assuming your function is called display_digit
>>> import time
>>> time.strftime("%H%M%S")
'105404'
>>> for d in time.strftime("%H%M%S"):
... display_digit(int(d))
...

Related

Making sure that nothing interrupts simulation, when doing it overnight (Windows 10) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
last night I was doing my first simulation that was supposed to take more time than usual programs. It was 1 000 000 steps of Monte Carlo in Ising model for several temperature configurations with generating animations all made in Julia language. I am using Windows 10 and I set my computer not to hibernate at all to avoid interruption. Despite, in the morning I faced that my computer was in hibernation mode and none of my simulations were made. I think the reason for this is that Windows made an automatic update that very night.
So that starts my question. Do you know some tricks to avoid situations like this, that an overnight simulation may be interrupted? I don't mean just the update thing - it is easy to manage but in this case I just forgot about it. Did you face some other problems in such long simulation in your programming expirience and have tricks how to avoid them? Or maybe do you have some ways to do such simulation in clouds (I have never tried this so it might be helpful too).
If answears depends on the languages that the code is written in, I could say that the most helpful for me would be tricks in python or julia, but all languages are welcome - maybe someone else will be interested.

Just being Curious [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
So I'v been learning how to program for about a month now. I just finished reading 'Invent your own games with python'. Before the book I had never seen a line of code. After reading the book I'm able to read code and understand what's going on. But that's about it. I got the syntax down and can use all the flow statements. I'm still not able to create my own projects and when I try to do a challenge online, I just sit there and stare at it not knowing where to start. Is this normal? Is this one of those things where one day I'm gonna wake up and It's gonna click in head. Any suggestions as too what I can do accelerate my learning?
I think you've reached the bliss point between knowing how to write Python and how to actually program.
Python is the tool, programming is the practice.
I was in your shoes a few months ago (I had finished Data Structures and Algorithms in Python, also a good book). I decided to look online for areas to practice and understand programming problems as well as improve my math skills (math shortcuts come in handy). Nothing really clicks until you've gotten a few projects accomplished.
Designing a game IS HARD and it may not be the best place to start but if that's where you want thing to click I'd highly recommend breaking games down as a programmer might: take a feature of a game, say SimCity's Sim.
What features in OOP terms does this feature have as attributes?
What does the object do?
What external classes/objects affect this object?
What does this object externally impact?
Since you're learning Python, learning how to use the OOP paradigm is crucial and designing projects around it allow you to use Python with greater strength.
It's absolutely normal to look at a problem and have no idea where to start.
That's a lack of experience. Get some.
This is where I start if I want to get a feeler for a new language: https://projecteuler.net/
There's plenty of resources online to test your skills and there's probably an offline community near you.
Yes, this is perfectly normal for any beginner.
What you need to do is just continue doing what you are doing.
The beginning will be difficult learning curve so aim for more beginner/basic level questions (i.e.: beginner level online challenges).
Develop plenty of your own programs for fun and whenever you get stuck ask online.
When other people answer your questions online look for the most elegant solutions (i.e.: quickest execution time, neat coding style, etc...) and try remember their solutions.
The fastest way (in my opinion) to learn code is to build your own programs for fun. Just never give up no matter how hard and frustrated it gets.

Serial Graphical LCD control with Python over SPI from Raspberry Pi [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to use the Sharp LS027B7DH01 LCD display here: http://www.sharpmemorylcd.com/resources/LS027B7DH01_Spec.pdf
http://www.mouser.com/ProductDetail/Sharp-Microelectronics/LS027B7DH01/?qs=muFWWzTLGEIPdePNc1A/NQ==
I need to control it with a Raspberry Pi programmed in python 2.7. It is a 400x240 display controlled via SPI, but no controller chip part number is identified. There are only 4 commands to write to it, and each display line is written one at at time. I've not been able to find an existing driver to use with it (but honestly, I'm not sure I am searching for the right things)
I could write a driver from the ground up to do text and graphics and everything, but it seems like a lot of work, and surely something like this has to already exist...
Any assistance would be appreciated!
The best solution I have found is to create bitmaps of the entire screen area with other tools such as pybmp, PIL, etc and simply dump that image to the LCD for display.

Running a program in windows with a specific name, so that I can close it mid run later [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I open many instances of the same program on windows, and many run simultaneously. Sometimes, something goes wrong with one of them, either its run time is too long, or it is taking up too much CPU and slowing everything else down, etc. In those instances, I want to shut the instance down, so that it doesn't get in the way, and run it again at some other time.
To accomplish this, I was thinking that maybe I could open the programs (just as i do now), but with a specific name. An example might be, PythonProg1, PythonProg2, etc. As the program runs, if something goes wrong, then I can shut down the specific instance that I want to shut down by ending that named instance.
Is there a way to do this?
Neil - are you opening them up by clicking on them? If that is the case, I don't think I can help you.
If you have a python script to run them, then it is simply a matter of assigning each one to a variable as you start it...
PythonProg1 = Popen(...
You could even just keep a list of them...
PythonProg = []
PythonProg.add(Popen(...))
You could then put in a timer or other test criteria and run Popen.kill() against any offenders.

Algorithm for teaching good vs. bad writing (Python) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
One of my web apps receives a lot of article submissions, some of them written not very well. How possible is it to create a tool to recognize "good" vs. "bad" writing just by providing it with a corpora of good and bad articles?
Note that these articles (at least the ones already processed) have been reviewed and graded, so in theory I could use these numbers to confirm output.
I don't have a background in creating "learning" algorithms, so even just a pointer to a foundational book on the subject would be helpful, particularly one written for the Python language.
I think that this would be a difficult learning algorithm to undertake. However, if you did want to have a go or are just interested to learn about the subject Coursera offer a number of free online courses that are worth checking out.
This course is not currently running for assignments etc, but you can watch the lectures in preview mode, from what I have seen this is well suited to beginners:
https://class.coursera.org/machlearning-001/lecture/preview
If you want some practice then I would highly recommend taking a look at Kaggle (http://www.kaggle.com/) which runs open competitions for data science / machine learning problems. Some of the competitions even have sample code to get you started, the titanic competition has some sample code in Python, although the problem being worked on is considerably simpler than the problem you have proposed.

Categories