Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to build programming logic?

Status
Not open for further replies.
I am computer engineering student(Our curriculum is 80% similar to electronics engineering in our country so you can call me electronics engineering student as well tbh). But this thing is relevant to electronics engineering as well so I am asking it here. I still don't know how to program. I of course can code very tiny tiny programs like prime number etc etc...But I am nowhere near the level of building big programs like using frameworks to make stuffs and so on.

I learnt c, c++ and python and bit of javascript. But all of them were useless. I learnt programming languages and not programming.

I know assebly language coding in 8085 and 8086 microprocessor. I didn't learn 8051 quite well though.

I think this question is relevant to electronics engineering students in my country(Nepal) as most electronics engineering students pursue career in coding like web development. Any way, coding is essential part of electronics engineering, we all know about that.


I am currently learning python. I learnt syntax of python. And I am currently solving codewars problems. I read other person's solutions as well and try to understand at least 5 different solutions to a problem. My logic has improved a bit in programming but I consciously want to know how to improve my logic in programming? What else can I do to improve my logic in programming? Any guidance will be extremely valuable.
 
The exact methods vary with the problem, but the most basic principle is break things down to sections, subsections and down to the lowest level functions or operations, create the code for those then use them as building blocks for the next higher level section and so on.

A "Bottom up" approach - like the old joke: "How do you eat an elephant"? "One bite at a time"!

If you cannot see an easy approach to do a whole problem in one go, start with the parts you can do.


In programming, another critical point for anything other than very simplistic problems is "never go back" - do not use wait loops or time delays, as they stop everything happening.

If something is not ready, skip forward to keep everything else working and check again the next time around the overall program loop.
Use "state machines" (basically a number that says what stage of a task you are at) so the next time around you know what you need to test or do, within each section.
 
The exact methods vary with the problem, but the most basic principle is break things down to sections, subsections and down to the lowest level functions or operations, create the code for those then use them as building blocks for the next higher level section and so on.

A "Bottom up" approach - like the old joke: "How do you eat an elephant"? "One bite at a time"!

If you cannot see an easy approach to do a whole problem in one go, start with the parts you can do.


In programming, another critical point for anything other than very simplistic problems is "never go back" - do not use wait loops or time delays, as they stop everything happening.

If something is not ready, skip forward to keep everything else working and check again the next time around the overall program loop.
Use "state machines" (basically a number that says what stage of a task you are at) so the next time around you know what you need to test or do, within each section.
My question is as a noob starting coder, how do I build my problem solving skills? How do I build my programming logic? How do I improve my ability to solve problems? What do I practice? How do I practice? That is all I want to know.
 
My question is as a noob starting coder, how do I build my problem solving skills? How do I build my programming logic? How do I improve my ability to solve problems? What do I practice? How do I practice? That is all I want to know.

Buy an Arduino Uno, and a few shields or modules, it uses C++ (super set of C) and there's loads of example code, tutorials and help on the Internet. Learn by doing, it's the best (only?) way.
 
Buy an Arduino Uno, and a few shields or modules, it uses C++ (super set of C) and there's loads of example code, tutorials and help on the Internet. Learn by doing, it's the best (only?) way.
I tried learning by doing but failed horribly at it. I was at times memorizing stuffs rather than understanding how things are built. Anyway I am currently learning python trying to enter web development.
 
how do I build my problem solving skills? How do I build my programming logic?
DO things!
Write simple text-based games, or programs to do unit conversions, calculate parallel resistors and such.

One of the first I wrote (on a home built machine in the mid 70s, no graphics, no commercial PCs yet) was a "Lunar lander".

That started at something like 20,000ft and 100 metres/sec descent, and just printed altitude and speed once a second.
If you pressed/held a key (actually a wired button), it fired the engine and added upward acceleration (decreasing speed), otherwise it accelerated down due to gravity & speed increased.

The aim was to get to zero altitude at less that 15ft/sec, or something like that.
(All my early stuff was in hand assembled machine code, as to start with the computer did not have enough RAM to run an assembler, never mind any kind of compiler)


[Nigel beat me to the "do things" point.]
Web development is very different, and python is categorically not an appropriate language for that, no matter what anyone online tells you!

For web pages, learn HTML first - you only need a text editor to create web pages.
That's what the web browser interprets to display pages and you cannot do anything more advanced until you understand HTML and can create pages with it. Just save the text files using "all files" and add the .html suffix, and you can then open them in your web browser just by clicking on them.

For more complex data-driven pages like on here, ebay etc., the html page is "printed out" by a script that uses a mixture of fixed html and data printed by the program. The best language to learn that is PHP (quite similar to C), which, on a web server, ties in to a MySQL database [using SQL] to save and load user data or page content etc.

The best sequence for a beginner web programmer is html, css (html styling), php, mysql, and only last javascript.
 
As several have stated above, find projects to do. Put something together at home, a weather station, a computer game, a plant watering system, etc. You will find that there is never a single way to code a project. In fact, I've thrown out code that I didn't like in order to try a completely different approach.

The modularity of languages available today will also allow you to tweak parts of your code (maybe the data logger in a weather station) while not changing other parts (the user interface or the sensor interface).
 
I learnt c, c++ and python and bit of javascript. But all of them were useless. I learnt programming languages and not programming.
No no no.... The syntax is a by product.... Learning any of those languages will help you loads.. All four of those are quite similar in syntax so when you start doing your logic stuff.. It will help!

Intel 8086 assembler is very similar to Zilog assembler.. But I think 8051 is more like 8600 ( Motorola) as it has two accumulators and all the R registers..

I digress... The only way to learn programming is doing... Make a project that needs the logic you need... Programable logic can also mean something else PGA come to mind... But the logic you seem to be referring to is "if-else" logic..
 
agreed ,
just start with a fun project you think you can do, you will either have it complete in 2 mths or you will be 6 mths in, and banging your head off desk cause you put a extra semicolon in the wrong spot or discover that a float is 32 bit in one lang but 24 in the other and similar annoying things.

once you have perfected your project you will realize that it could use a ver 2.0. and really that s a rabbit hole on its own, or else if satisfied then move on to one you feel will be more complex.

my first project was a DTMF robot that plugged in to a cell phone headphone jack using discrete logic, then it evolved when i learned micro controllers exist, and then again the robot was upgraded to run off TV IR remote.
my second one was a 5x5x5 rgb led cube, after i got it working i attached serial interface and created desktop app to easily create animations on it .
the third was a small fully-automatic coilgun attachment for the robot and an IR chronograph to measure muzzle velocity.
 
Last edited:
The best way to develop logic and improve programming skills is to start working on a particular language and project, Once one language you learned then you can easily build logic with another language. Consistent work only helps to improve your logic-building capacity!
 
I of course can code very tiny tiny programs like prime number etc etc...But I am nowhere near the level of building big programs like using frameworks to make stuffs and so on.
All code (should) consist of tiny tiny programs that are strung together to make a bigger one. Using "frameworks" is using someone else's code, much better if you write it yourself one tiny tiny bit at a time. Breaking a large program down into usable chunks is a skill in itself.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top