Helloooooooooo, still here, this week was about microprocessor programming, I thought it was easier, and it is easy, is just that is different from programming just in python. There are many things to know to run a program. But first...
A microcontroller is kind of a head of a machine, is the thing that processes all the given information. This things have 3 main things, the code, the sensors and the actuators,
within the physical part (sensors and actuators) there is every electronic component, and this electronic components work according to the given code.
The code are the instructions of what to do with every connected component. The code can be written in many languages such as, micropython, arduino, c++, rust, etc.
Also, is important to mention that there are many many MANY types of micro controllers, from arduino, raspberry pi pico, tiny, and many many other.
NOTE, is important to read the information sheet of the micro controllers to know what does it offer and pick the one which more adjust to your necessities.
NOTE2, many micro controllers can be programed with different languages, not using 2 languages at the same time, you have to install the language and if you want to change language
you have to desinstall the language and install the new one and so rewrite the hole code.
Well I didn't picked it but is what our fablab will give us: raspberry pi pico
The first steps are
Now it's time to start programming, here is very important to keep in mind the libraries, this are like packages of information
that allows you call some predefined commands with specific functions and make the programming process a lot easier.
In my case I just used machine and utime.
led = machine.pin(0,Pin.OUT)
boton = machine.Pin(0,machine.Pin.IN, machine.PULL_DOWN)
PWM means "pulse with modulation", and this is basically a way of controlling pulses. Think about it like a every day up and down continuos signal, 0 and 1.
Where the amplitude will be the voltage (just off or on), the period is the complete cycle, and a cycle has an up section and a down section.
This kind of pulses are defined by the percentage of up time (called "duty" when programming). So for example, if we have a period of 1 second with a max voltage of 5V
and a duty of 50% the led will turn on 0.5 seconds and will turn of for 0.5 seconds. A duty of 30%, the led will turn on 0.3 seconds and turn of 0.7 seconds.
I wanted to do a lot more things but, I couldn't JAJAJA SAD,
so I ended up doing a "copy" program. This program asks you for a period of time, activates a buzzer to tell the beginning of the data capture,
and you have to press a push button whenever you want within the given time.
When the time is over the led will turn on the same time and order you pressed the button.
NOTE I used wokwi to make this simulations, this website has arduino, pico pi, ESP32 micro controllers and many
languages like, arduino, micropython, and rust.
NOTE2 I used micropython, I've worked with python before and is one of the easiest programming languages.
And here a little demonstration of how it works.