Skip to main content
35 votes
Accepted

Raspberry PI controllable car (code for a 6-year old)

The implementation of forward is horrible. The only correct way of expressing it is to make all four motors go forward. As an analogy, how would you react if your ...
Roland Illig's user avatar
  • 21.9k
27 votes

Raspberry PI controllable car (code for a 6-year old)

From my experience, kids understand DRY without explanation, and in fact they are very bored by the repetition. which led to some motors accepting "backwards" as "forward" This is I am afraid a ...
vnp's user avatar
  • 58.7k
20 votes
Accepted

Sort-of Alexa clone using Python on a Raspberry Pi

This is very interesting. I love it. Good work. Critcism: with sr.Microphone() as sauce: From https://pixabay.com/photos/tomato-soup-tomato-soup-sauce-482403/ ...
JaDogg's user avatar
  • 4,561
17 votes

Sensor logger for Raspberry Pi in a stratospheric probe

Do not call main recursively. You are setting yourself up for stack overflow. Consider instead ...
vnp's user avatar
  • 58.7k
15 votes
Accepted

Car computer in python / GPS tracking

There's A LOT going on in your code but I'll try to give you some hints and some suggestions regarding the overall structure/workflow of the code. you have really abused the use of ...
Grajdeanu Alex's user avatar
14 votes
Accepted

Raspberry PI controllable Christmas Tree

I would suggest to separate the concerns of coloring and animating. Now, in particular theater_chase_rainbow duplicates code from other methods. Instead, have ...
Janne Karila's user avatar
  • 10.7k
11 votes
Accepted

Sensor logger for Raspberry Pi in a stratospheric probe

Have you already executed the code to see how it performs and if the battery will last? There is that famous Donald Knuth quote saying premature optimization is the root of all evil (or at least most ...
Kim's user avatar
  • 226
10 votes
Accepted

Raspberry-Pi morse-code LED

I'm aware that you are a beginner. So I will try to improve your code starting from the most obvious problems and try advance step by step. Variable names Names like ...
stefan's user avatar
  • 2,994
8 votes

Sensor logger for Raspberry Pi in a stratospheric probe

Opening and closing files takes resources: with open('babar.txt', 'a') as f: f.write('a'*10000) takes 300 micro-seconds while: ...
Benoît P's user avatar
  • 809
8 votes

Loop to print changes in irrigation state to turn on and off a pump when water is low

Just curious, but have you checked CPU usage ? Programs that run in a while loop can be terribly inefficient and taxing. Here you are just probing a sensor, this does not look like a computationally-...
Kate's user avatar
  • 8,778
7 votes

Raspberry PI controllable car (code for a 6-year old)

I wrote a Pi+python control program so I had a quick look at what I did. Interestingly I noticed that I seem to have had the same problem with forwards and backwards. I found this comment: ...
Oldfart's user avatar
  • 171
7 votes
Accepted

C++ code reading from a text file, storing value in int, and outputting properly rounded float

This is good use of the appropriate stream: ...
Toby Speight's user avatar
  • 88.7k
6 votes
Accepted

Measure distance using echo signal from Ultrasonic sensor

raw_ultrasonic_measure measures the duration of an echo staying high. It is not related to the distance in any way, it is just a duration of trig signal. You need ...
vnp's user avatar
  • 58.7k
6 votes
Accepted

AppJar number pad and keyboard

Python has an official style guide, PEP8. It won't hurt getting familiar with it, since it helps keeping your code readable, consistent and ready for others to mess with. Combining Italian and ...
Mast's user avatar
  • 13.9k
6 votes

Car computer in python / GPS tracking

Other minor points: Generators Your generator - for line in s: yield line.replace('\0','') can be simplified to ...
Reinderien's user avatar
  • 71.2k
6 votes

Loop to print changes in irrigation state to turn on and off a pump when water is low

If I understand what you are trying to do, I think you can (1) remember the prior state, (2) print only on changes, and (3) select the message to print based on the new state. ...
FMc's user avatar
  • 13.1k
6 votes

C++ code reading from a text file, storing value in int, and outputting properly rounded float

Naming: Personally I find Snake case word_word_word is more of a Python style. Where Camel case wordWordWord is more C++. ...
Loki Astari's user avatar
  • 97.7k
5 votes
Accepted

A baby monitor using a Raspberry Pi to send push notifications when triggered by noise

Bash ...
Peter Taylor's user avatar
  • 24.5k
5 votes
Accepted

Signal output on Raspberry Pi that acts as input for FPGA

You should start by organising your code better. Try to avoid global variables and group together code in functions. In addition, you should learn about list comprehensions. They make initializing ...
Graipher's user avatar
  • 41.7k
5 votes
Accepted

Streaming H264 video from PiCamera to a JavaFX ImageView

Architectural Ideas Let's start at the Architecture of your Application and the data transfer. There's basically two places where we can optimize the performance of your application. I'm ignoring ...
Vogel612's user avatar
  • 25.5k
5 votes

Alerts by phone calls for location-relevant Israel Home Front Command alerts

always running The requirement is perfectly sensible, but the implementation is weird and inconvenient. make sure that the main program is running: ...
J_H's user avatar
  • 43.3k
4 votes

Measure distance using echo signal from Ultrasonic sensor

Oops... ...
Daniel Jour's user avatar
  • 1,591
4 votes

Measure distance using echo signal from Ultrasonic sensor

Take these comments together with the comments of others, not instead of them. They have already said much that needs saying. ...
aghast's user avatar
  • 12.6k
4 votes

Sort-of Alexa clone using Python on a Raspberry Pi

Just some small things: find_path could be neatened up a bit using any and chain from ...
Carcigenicate's user avatar
4 votes

A PHP script used on my home server to download YouTube videos

Security Command injection I made a small patch by disabling the characters " " (space), "&", and "|". This can easily be bypassed. Example: ...
tim's user avatar
  • 25.3k
4 votes
Accepted

Error handling on temperature sensor

Every 4th measurement fails is a pretty high error rate. The preferred course of action would be to root cause the error and fix it. Meanwhile, since the error seems to be transient, you may want to ...
vnp's user avatar
  • 58.7k
4 votes

Car computer in Python / GPS tracking VERSION 2

First, I need to say that this is a really cool project; quite fun. You ask: Other than consistency, would you see any advantages in using python? Bad code can be written in any language, but it's ...
Reinderien's user avatar
  • 71.2k
4 votes

Car computer in Python / GPS tracking VERSION 2

There is a potential race condition in update_display() ...
RootTwo's user avatar
  • 10.7k
4 votes
Accepted

Loop to print changes in irrigation state to turn on and off a pump when water is low

I agree with @Anonymous that you should not loop continuously like that, or you'll waste energy and CPU time continuously checking the values. To solve this you can just sleep, wake up every minute, ...
Francesco Pasa's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible