Getting started with pyBoard & electronics

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
HLA91
Posts: 13
Joined: Sat Aug 02, 2014 9:02 pm

Getting started with pyBoard & electronics

Post by HLA91 » Tue Jun 07, 2016 8:27 pm

Hi All,

I hope this is the right place, I purchased a Pyboard when they first came out, originally my employer was interested in using the board for RFID/Bluetooth purposes but went with a off the shelf solution.
I came up with a little project for myself of building a robot utilising servo motors to drive wheels and IR sensors to detect obstacles, now my only problem is I have never done anything electrical before. I haven't ever used GPIO Pins, used a soldering iron, built a circuit, or even touched a breadboard so I'm a total noob in this dept.
Is there any recommended tutorials/books to get me going to learn about what all the different pins mean and how to utilise them without blowing something up or frying my board? I have been loaned a breadboard and an LCD screen from a friend, I'll try and post a picture tomorrow to see if anyone can identify the model as I cannot see any names/serials.
My first idea is to order a soldering iron and solder on female headers to enable me to start playing about, any objections?

Thanks

HLA91

markxr
Posts: 62
Joined: Wed Jun 01, 2016 3:41 pm

Re: Getting started with pyBoard & electronics

Post by markxr » Tue Jun 07, 2016 9:06 pm

Soldering on female headers is certainly a good idea.

I'd recommend you find your local hackspace, where you'll probably find someone who can help.

Be very careful with boards which only support 3.3v - don't feed 5v into the inputs, otherwise you may let the "magic smoke" out i.e. destroy your chip.

For inputs, always put a big(ish) resistor, say 1k, in series with a digital input especially if you're not 100% sure it's the correct pin.

Mark

HLA91
Posts: 13
Joined: Sat Aug 02, 2014 9:02 pm

Re: Getting started with pyBoard & electronics

Post by HLA91 » Wed Jun 08, 2016 12:04 pm

I have just ordered some resistors so once they arrive I can start playing a bit more. I have found an online guide teaching me how to use a breadboard and a Raspberry Pi so I'm going to try and work out how to use the PyBoard in place of the Pi. Out of interest I have a led screen being loaned to me does anyone know if it will work with my PyBoard.
ImageImageImage


Sent from my iPhone using Tapatalk

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Getting started with pyBoard & electronics

Post by dhylands » Wed Jun 08, 2016 3:41 pm

The LCD itself looks like one of the HD44780 ones.

I have code for driving those using gpio, or a couple of different I2C backpacks.
https://github.com/dhylands/python_lcd/tree/master/lcd

I'm not familiar with the backpack on your LCD, so I don't know if it will work or not. The markings tend to indicate that its a serial (i.e. UART) based interface.

HLA91
Posts: 13
Joined: Sat Aug 02, 2014 9:02 pm

Re: Getting started with pyBoard & electronics

Post by HLA91 » Thu Jun 09, 2016 8:37 pm

Thanks for the replies, much appreciated. After purchasing some resistors I finally actually did something with my PyBoard last night and hooked up an LED via a breadboard I'm quite proud of myself at this little achievement.
One thing that has confused me though, I had a wire going from X1 -> resistor -> Anode of LED, and from the Cathode of the LED straight to GND, yet on another diagram I've seen they suggest putting the resistor on the cathode side of the LED ? Does it make any difference when side the resistor goes?
Is there a good way of learning what each Pin on the board actually does in simple terms that I would understand?

Thanks again

HLA91

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Getting started with pyBoard & electronics

Post by dhylands » Thu Jun 09, 2016 8:39 pm

Which side the resistor goes on doesn't make any difference.

Here's a good thread which provides some introduction to some of the common functionality you'll find (SPI, I2C, UART).
http://electronics.stackexchange.com/qu ... -how-do-th

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Getting started with pyBoard & electronics

Post by pythoncoder » Fri Jun 10, 2016 9:49 am

dhylands wrote:... Here's a good thread which provides some introduction to some of the common functionality you'll find (SPI, I2C, UART).
The link seems to have wound up in /dev/null ;)
Peter Hinch
Index to my micropython libraries.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Getting started with pyBoard & electronics

Post by dhylands » Fri Jun 10, 2016 5:11 pm

pythoncoder wrote:
dhylands wrote:... Here's a good thread which provides some introduction to some of the common functionality you'll find (SPI, I2C, UART).
The link seems to have wound up in /dev/null ;)
Thanks - I went back and edited my post and added the link.
Stupid computers still do what I say, not I what I want :)

HLA91
Posts: 13
Joined: Sat Aug 02, 2014 9:02 pm

Re: Getting started with pyBoard & electronics

Post by HLA91 » Fri Jun 10, 2016 5:24 pm

Thanks for the link, I had a read and it all makes a bit more sense to me now. My next question is, I have a Obstacle Avoidance IR sensor with 3 pins, GND, VCC & OUT. Now I read the pin sheet and I figured the VCC should go to the 3V3 pin, as the sensor can take from 3.3->5 [so I don't need a resistor I assume], I connected the GND to the GND on the PyBoard, now my next move is to connect the OUT, now am I right in thinking I can use any of the Yellow labled X or Y pins shown here?
Also, once I've got the OUT connected to a pin [i.e. X2] I could use the code

Code: Select all

p_in = Pin('X2', Pin.IN, Pin.PULL_UP)
p_in.value() # get value, 0 or 1
in a loop to continually read the input, or at least notify my of a change?

Thanks

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Getting started with pyBoard & electronics

Post by dhylands » Fri Jun 10, 2016 5:38 pm

If it's a digital output from the IR Sensor, then you can use any of the yellow pins.

Your code snippet looks ok to me (I didn't test it to see if something subtle was missing).

You can use ExtInt to detect when a pin changes without having to poll.
http://docs.micropython.org/en/latest/p ... xtInt.html

Here's an example that uses the switch as the input:
https://github.com/dhylands/upy-example ... _toggle.py

Post Reply