How to structure my code

Hello all,

I am making a walkie talkie type device with a potentameter, button, oled screen and a microphone and speaker im wondering whats the best way to structure my code and structure it in the best way. please let me know if there any recommended way.

I moved your topic to an appropriate forum category @ioack .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I think if you work on integrating the components one at a time and getting a feel for each chunk of code, the answer will become self evident for your own personal style.

One structure is the IPO model. That stands for Input, Processing, Output. Read the inputs to gather information, process the information, act on the information.

A state machine is a way to organize the program. A state or states to get the input data, state or states to process and state or states to ourput to dislpay, speaker, etc.

Thank you for the information i will look into this.

@ioack

Below is a simulation with OLED, button, potentiometer, slider, and speaker (and switch to turn off speaker).

I have divided it into functions, which allows me to edit, include or exclude a device without doing damage to the main code.

@xfpd

Where is any walkie talkie functionality?

Why do you comment what functions do and not why?

Why do you think a delay(10); in loop would allow any useful audio processing?

Looks like that stuff was generated by ChatGPT.

does the walkie talkie use separate radio and audio circuits controlled by the pot and button and the software is just some fancy interface?

or is communication of something more related to software such as WiFi, Bluetooth, SMS, ... because the communication software would be the challenging part

I might take that as a compliment, but ChatG has a personality.

The speaker is the talkie along with the slider as an analog(ue) input (as the mic) because the sim has none (yet). Button can initiate the PTT. Pot can be squelch and volume. OLED... who needs one on a walkie talkie?

For post #1. I consider what and why similar enough to send the message in context... but I see your point... as it would have answered question #1.

This number was settled upon for the sim. Too little and the sim wouldn't even open the Serial Monitor. Too much and the tones (talkie) would drag. I commented-out the "walkie-talkie" part because that can be solved with a GSM... or a USD$10 walkie-talkie. I neglected to remove the delay after removing the walkie-talkie part.

Whoever is the Badges Minister out there, I would like a badge for "produces chat-like code."

1 Like

Hi, @ioack
Welcome to the forum.

Or are you making an intercom system with the stations connected by wires?

Tom.. :grinning: :+1: :coffee: :australia:

It is not.

Then, you made me happy.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.