Hello Everyone. I am just getting back to re learning Arduino IDE after several years of refraining from my electronics hobby.
Once returning to learning i purchased a uno R4 wifi and an Adafruit TFT shield, then discovered the ESP 32 S3 dev boards. ( i buy the ones from Digikey or Freenove because they are high quality).
Well thats my background info.... ive made a lot of successful projects already after learning the hard way a few months in. But i feel im missing the finer points of programming. With AI giving sample code and all the support for Arduino i have a single glaring question:
How do i learn the finer points of coding here? Just staying after it and keep making projects? I assume some of it will sink in over time. I feel kinda spoiled with all the libraries and support.
That being said theres still tons to learn....
Any recommendations on returning noobs are greatly appreciated. ![]()
-
Oh do we have a deal for you.
Not really. -
This is an offering for people like you (maybe newer persons) who want a review.
-
When you go through the post linked below try to understand the schematic, the sketch, and the flowchart.
When you have questions, we can answer them.
This is awesome and hands on what i need. I will go through this and write down questions as i go. Thank you very much!
Greetings. I am looking at this on my phone, and this is a very professional looking program. Can you enlighten me on what a state machine is, and blocking behavior? I am only familiar with debouncing switches using delays which arent the best ive noticed.
The schematic makes perfect sense, so far.
My intention here is to fully build this project and understand the flowchart and code. Once i have that up and running...ill understand more.
Thank you × 1000 for this learning experience
Take a course in C/C++
Some people like The Pragmatic Programmer but my favorite overall programming guide has always been the classic Code Complete. Learning to properly design and structure code is far more important than how well you know the language.
- We often use state machines to manage sequencing.
@PerryBebbington has a good analogy:
Lots of replies about the need for a state machine. I'm guessing you are concerned that you don't know what a state machine is and that it might be a difficult concept to learn.
I think you already know what a state machine is, everyone knows what one is, it's just that you don't know that's what it's called. There are lots of things in life that operate as a state machine but the example I like to use here is a restaurant, a restaurant operates as a state machine.
.
A restaurant has states like:
Waiting to be seated
Reading the menu
Ordering food
Waiting for food
Eating
Getting the bill
Paying
-
We can cover a more evolved State Machine in a new example added to the same post linked a few post back.
-
Building up the circuit and following the example would be a good thing to do, we can proceed at your timetable.
-
Blocking behaviour is when a section of code hogs the processor preventing other code from executing.
delay(…) and while(…) are two examples.
A micro-controller can do 1000 things at the same time, or rather it can do 1 thing at a time but do 1000 (or more) of them so fast that it looks to the user like it's doing 1000 things at the same time. Blocking code is any code that prevents that, anything in one of those thousand things that hogs the CPU so it can't do any of the other things.
These replies are all very helpful.
Especially concerning the state machine - restaurant example and the explanation of blocking behavior.
I do have a reference book, and i actually have taken C++ courses before when i was younger. Anyhow ill get started building this later.
- The link below is a dogs breakfast of things for you to examine in your spare time
:
This tutorial shows several different ways of flashing some LEDs at the same time. All the examples utilise a simple state machine and non-blocking, millis based timing. The idea behind the tutorial was to give different ways to achieve the same thing so if one of them doesn't make sense to you hopefully one of the others will.
I dont have a servo, but i do have a lot of different power supplies, voltage regulators and mosfets. I can certainly purchase one.
You have me curious because ive never learned anything about servo motors, except that when the one in my car goes bad that drives the blend door for the A/C its time to stand on my head and remove it from the dash. Lol
Your response here definitely clicked a light bulb (or LED) in my head
-
We will add some servo code to the sketch when we get into discussing State Machines.
Suggest you pick up a 4 battery (AA) holder to power the servo.
For now you can remove one of the batteries from the holder to power off the motor. -
If you don’t have a 12v power supply and 12V relay you can use 5v versions, or we can just use LEDs.
-
Is your Arduino controller 5v or 3V3 logic ?
-
Do you have an Arduino UNO rev 3 board ?
I can order the servo and batteries and have them here by the end of the week.
I understand the need for batteries because most power supplies in my limited experience dont have that push to power a strong motor
The Arduino R4 wifi itself outputs 3.3v logic signals, so ive had to be careful with it to calculate resistors to power LEDs and character displays. I assume it had to be 3.3v to be home to the esp32s3. This board does have a 5v output from the regulator, but admittedly i havent learned all about this board yet.
I do have a 12v power supply its an old ATX pc power supply that i converted to be a bench top supply. As far as relays go, i have a few automotive relays that should do the job but ill have to do some soldering and dig to find them
I do not have an Uno R3 unfortunately. So will i need a logic level shifter as well?
I can order the servo and batteries and have them here by the end of the week.
- Amazon has good inexpensive choices, I like the MG996 servos (5-6 dollars), check prices.
I understand the need for batteries because most power supplies in my limited experience don't have that push to power a strong motor
- Yes, motors like a servo often need 1.5A which a 6V AA battery pack can provide.
The Arduino R4 wifi itself outputs 3.3v logic signals, so ive had to be careful with it to calculate resistors to power LEDs and character displays. I assume it had to be 3.3v to be home to the esp32s3. This board does have a 5v output from the regulator, but admittedly i havent learned all about this board yet.
- We can work with the UNO rev 4.
I do have a 12v power supply its an old ATX pc power supply that i converted to be a bench top supply. As far as relays go, i have a few automotive relays that should do the job but ill have to do some soldering and dig to find them
- Seems like a bit of work, let’s just use a LED for now, you can be assured the relay circuit shown does work as long as the relay coil resistance can limit the ON current to about 200mA.
i.e. For a 12v relay, 12V(supply) ÷ .2A(2N2222 current) = 60Ω (coil resistance) minimum resistance.
I do not have an Uno R3 unfortunately. So will i need a logic level shifter as well?
- No you will not need a logic level shifter for this discussion.
Getting an Arduino UNO Rev 3 (maybe avoid the USB CH340 clone) would be a good christmas present
Will do. Ill get started building




