Examples (similar to Arduino)
Examples (similar to Arduino)
Hey there,
I'm working on a bunch of working examples for simple functions that could be used as part of the 'Getting Started' guide. Similar to Arduino's examples folder from where every beginner's helloWorld into Arduino is Examples > Basics > Blink
The purpose of this is for beginners to easily look up working code and try to replicate it for their projects.
I've only just begun playing with uPy. So there are only a few examples for now and it's likely I may have messed up in a few places - have a look and let me know if there's something wrong.
Will be working on adding more to this repo on weekends and after work - my way of getting using to this (haven't coded python in quite a while as well). Contributions are welcome.
https://github.com/mithru/MicroPython-Examples
I'm working on a bunch of working examples for simple functions that could be used as part of the 'Getting Started' guide. Similar to Arduino's examples folder from where every beginner's helloWorld into Arduino is Examples > Basics > Blink
The purpose of this is for beginners to easily look up working code and try to replicate it for their projects.
I've only just begun playing with uPy. So there are only a few examples for now and it's likely I may have messed up in a few places - have a look and let me know if there's something wrong.
Will be working on adding more to this repo on weekends and after work - my way of getting using to this (haven't coded python in quite a while as well). Contributions are welcome.
https://github.com/mithru/MicroPython-Examples
Re: Examples (similar to Arduino)
Following your lead, I also created a repository of some sample code I've written.
https://github.com/dhylands/upy-examples
Feel free to use/rework any of this that might be expanded into more tutorial like material.
https://github.com/dhylands/upy-examples
Feel free to use/rework any of this that might be expanded into more tutorial like material.
Re: Examples (similar to Arduino)
Thanks! Looks good. I'll update the repository and re-arrange the order such that the learning curve is not too steep.
Re: Examples (similar to Arduino)
Is there anyone can give me some example of using ADC class from any device like potensiometer or distance sensor?
Re: Examples (similar to Arduino)
Check out the 'Potentiometer' example in here:
https://github.com/mithru/MicroPython-E ... /02.Inputs
https://github.com/mithru/MicroPython-E ... /02.Inputs
Re: Examples (similar to Arduino)
That's great! Thanks, mithrumithru wrote:Check out the 'Potentiometer' example in here:
https://github.com/mithru/MicroPython-E ... /02.Inputs
Re: Examples (similar to Arduino)
IMHO it is not that reasonable to split an example into the two scripts 'boot.py' and 'main.py'. As far as i do understand the 'boot.py' should only influence basic bahaviour of your pyBoard and not be used as a place to initialize the "program" on it. It feels like you are using the 'boot.py' like the 'setup()' method on Arduino.mithru wrote:Check out the 'Potentiometer' example in here:
https://github.com/mithru/MicroPython-E ... /02.Inputs
To describe it further, I'd say that you should only alter the 'boot.py' to change fundamental things like enabling different USB features (serial console over USB and mass storage).
Re: Examples (similar to Arduino)
I'd also recommend having the files named after the example rather calling them main.py
Then you could copy several of them to your sdcard and just import them to run the example
Then you could copy several of them to your sdcard and just import them to run the example
Re: Examples (similar to Arduino)
Got it. Makes sense. Thanks for the feedback, guys. Will update this tomorrow evening my time.
EDIT: Changes have been made.
EDIT: Changes have been made.
Re: Examples (similar to Arduino)
I was looking for an example like https://github.com/dhylands/upy-example ... c_test2.pydhylands wrote:Following your lead, I also created a repository of some sample code I've written.
https://github.com/dhylands/upy-examples
Feel free to use/rework any of this that might be expanded into more tutorial like material.
In trying to understand the example. One point I am confused about is the line 25
Code: Select all
def ic_cb(tim):
Code: Select all
ic = pyb.Timer(2, pin=ic_pin, mode=pyb.Timer.IC, channel=4,
prescaler=83, period=0x0fffffff,
ic_polarity=pyb.Timer.IC_POLARITY_BOTH)